cut is a filter program which extracts fields or columns of each line of input.

learn more… | top users | synonyms

1
vote
4answers
27 views

cut column 2 from text file

My text file has no delimiter to specify separator just spaces, how do I cut out column 2 to output file, 39 207 City and County of San Francisc REJECTED MAT = 0 78 412 Cases and ...
1
vote
1answer
35 views

changing a specific 'column' inside a txt file

I have a file with thousands of entries like this: 6/05/2016,32,34,40,45,48,,01,10 10/05/2016,02,26,27,40,49,,05,10 13/05/2016,07,15,28,31,42,,10,11 17/05/2016,15,27,32,36,39,,03,10 I want to ...
3
votes
1answer
44 views

Modify values in a column based on number of colons it contains

I would manipulate the contents of the second column based on the number of colons it contains. If the second field contains more than one colon then I would require the content before first colon ...
0
votes
2answers
48 views

cut -c won't work on my .sh file [closed]

I have tried the following commands cut -c-11 ifshell.sh cat ifshell.sh | cut -c-11 ifshell.sh cat ifshell.sh | awk '{print $1} | cut -c-11 ifshell.sh But every time I get the full contents of ...
1
vote
2answers
34 views

cut out specific fields from text file [duplicate]

I have a text file with 9 fields separated by : survey:m1111771::rent:travel:::Morning: How do I pull field 1 and 8 only to a separate file for example it would look like this, survey:Morning
0
votes
1answer
27 views

Recursive Directory search, Showing most recent file in folder

Can someone point out where am going wrong please. Am doing a directory search (Based on the folder structure and file type) The folder structure is the same for every customer. Just the customer ...
1
vote
4answers
46 views

Using cut to return the middle of a string

I have an xml string echoed to stdout along the lines of <xml:attribute>{41c33a-4893b-3627a-617a}</xml:attribute> I want to return the string {41c33a-4893b-3627a-617a} in this case. I ...
3
votes
2answers
42 views

pipe process output to command split by line and whitespace

On the system I'm using I often need to cancel jobs I run. I can check my jobs like this: $ showq|grep jquick 2001744 jquick Running 120 00:08:26 Mon Apr 11 11:06:02 2002020 ...
0
votes
0answers
15 views

Dictionary - synonyms

I have czech czech-finnish dictionary and I have two czech synonyms in one row. Example: záchod (m); toaleta (f) WC; käymälä; miestenhuone; naistenhuone; vessa Synonyms are divided by semicolon ...
-1
votes
3answers
43 views

How to filter log file for string inside single quotes?

I have a log file, which outputs information this way: 2016-01-01: foo bar fnord 2016-01-01: this is static 'this is of interest' some blob bar 2016-01-01: this is static 'this is of interest' some ...
1
vote
1answer
87 views

I need to merge multiple .csv files together side by side with unequal number of rows

I have anywhere from 3-5 .csv files and need to be able to merge them together while keeping everything in its respective columns below is an easy example with files with varying number of rows. file1 ...
3
votes
3answers
41 views

Strings - Extract File Version Recursive

I have been using strings to extract and compare file versions between directories. I don't seem to be able to do this recursively. The method I have been using per file is: strings -e l ...
2
votes
5answers
87 views

how to cut fields of a directory name?

I have directory named 140905_M01771_0112_000000000-ABBYT. I want to get the third field i.e. 0112. I tried: cut -d _ -f 3 131230_M01771_0032_000000000-A7874 giving me error: cut: ...
0
votes
2answers
74 views

Using Both Grep and Cut

I want to grep the output of tcpdump and cut some part of it but the command below is not working. tcpdump ... | grep -i --line-buffered "..." | cut -d'&' -f1,2 Do you know what is the problem? ...
1
vote
2answers
37 views

how to store output of echo and cut to a variable

I have a file named test which has two columns one having ID and other having status. I want to loop through the file and print IDs where status have one particular value (e.g. 'ACTIVE'). I tried ...
1
vote
1answer
73 views

cut column range sed/awk/cat

I'd like to cut a certain range of text (i.e. characters 17-63) repeatedly from a *.txt file, which is several thousand lines long. One line looks like this: ...
1
vote
1answer
46 views

grep content between two starting bracket

Below is file output that I want to access [1] RsyncCommand: 0 Number of files: 18 Number of files transferred: 0 Total file size: 24.01M bytes Total transferred file size: 0 bytes Literal data: 0 ...
-1
votes
1answer
34 views

cut command behaving differently when its output is “ * ” [duplicate]

I am trying to create a shell script, below is a part of which where i am trying to extract some value from a record in a file: tgt_val=`cat $file_name | grep "$string_name" | cut -d"|" -f$column_no` ...
1
vote
3answers
97 views

Using bash variable substitution instead of cut/awk

Can I use bash variable substitution to extract a piece of a variable based on a delimeter? I'm trying to get the immediate directory name of a filename (in this case, foo). $ ...
2
votes
2answers
93 views

“cut” hangs when using “tail -f” in combination with “tr”

I'm try to pipe chat log files to some speech output, and want to remove timestamps with cut and remove special characters with tr. Unfortunately, cut seems to halt when using it with tail -f in ...
1
vote
2answers
47 views

How to extract first part of filenames with same suffix?

I want to get at the prefix of a variable-length filename. In: some_filename_123-uniq.tar.gz Out: some_filename_123 In: some_filename_1-uniq.tar.gz Out: some_filename_1 This does the exact opposite ...
2
votes
3answers
64 views

split a file by a character and add it to the data

I have a question that I would like to make simpler, how do I split the second field of a file (space delimited) by an underscore and add the second part as a new field to the data (output as tab)? ...
0
votes
1answer
66 views

bash: How to determine the largest number (newest version) from: ls *.tar.gz | cut -c 2-4

Hi I'm trying to get the largest number (newest version) of a file, I got a bunch of tar.gz files in a directory, versions of some software in the format v${version_number}_software.tar.gz, where ...
1
vote
1answer
40 views

Match data from array to data from file?

I'm trying to match up the data from an array the lists the days of the week like this: MONDAY TUESDAY WEDNESDAY THURSDAY FRIDAY SATURDAY SUNDAY The files data reads like this: Name1,Tuesday ...
1
vote
6answers
144 views

string manipulation without awk or sed

any help on this problem is appreciated I have a text file with the following format We can safely assume that the names are always three characters long, profession 7 characters and salary 5 ...
1
vote
2answers
198 views

how to do inverse cut?

I am sill new in this. I would like to ask, how to inverse the cut? Example; ./24feb/frfr I want after cut command, the result will be ./feb/frfr. How to do it?
6
votes
7answers
272 views

How can I apply `cut` to several files and then `paste` the results?

I often do operations like paste <(cut -d, -f1 file1.csv) <(cut -d, -f1 file2.csv) which is very tedious with more than a few files. Can I automate this process, e.g. with globbing? I can ...
2
votes
1answer
115 views

Cut command does not separate by tab in script

Note : I don't know how to insert tabulation in my text, I replaced it by [tab] I have a list file name value separated by a tabulation : host1[tab]ip1 host2[tab]ip2 host3[tab]ip3 host4[tab]ip4 ...
3
votes
2answers
130 views

How to split a file by counting digit numbers within a row?

I have a file with 45000 character within each line and I I want to split the original file based on specific numbers of character within a line. as an small example my input file looks like: ...
0
votes
2answers
387 views

Initializing a variable with echo

So, I'm trying to store a part of the name of a file into a variable for other uses. So, if my file was named hello123.txt and I want to store the 123 part. So I try num= echo $file |cut -c6-8 ...
5
votes
4answers
302 views

how to split a file into separate files based on the column headers in original file?

I would like to split a file to different files based on the information in the first line. For example, I have: Input: 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 3 3 3 3 3 3 4 4 4 4 4 4 4 30 30 30 30 0 2 2 0 2 ...
0
votes
3answers
67 views

Null value than rename file

I have a shell to a task but I should handle the null value in this. So in the task i cut the part of a word and i delete or rename the file, but need another if element for null. For example: I ...
3
votes
3answers
69 views

How do I cut a string already separated by spaces?

Lets say there's a string like this test="1/2/3 4/5/6 7/8/9/0" They are separated by spaces, as well as '/'. I want to return a result like this by taking the second field of each string segment. ...
0
votes
1answer
57 views

Fetch second and fourth column from a file

Problem Statement I am not able to get the values in second and fourth column. Tried grep -i "AUGC\|AACN\|AACY" output.csv | cut -d ',' 2,4 DATA ...
0
votes
2answers
71 views

File size after cut

I am trying to verify if I split large file correctly into multiple pieces. As an toy example, I have a file out_sample: 123456789012 123456789012 123456789012 123456789012 123456789012 This has 64 ...
1
vote
1answer
164 views

Can't redirect cut output

When I try to redirect the output of cut it always seems to be empty. If don't redirect it, the output shows in terminal as expected. This is true for OS X 10.10 and Linux 4.1.6. This works: ...
0
votes
1answer
65 views

bash: cut command produces nothing (just a blank line)

I have a problem with being able to echo a part of a string Here is a simplified version: t=no_1187985:/home/my.name/testing/no I want to echo no_1187985 only so: tt=$(echo $t | cut -d":" -f 1) ...
0
votes
2answers
913 views

Bash to join column from multiple files

I have around 20 files in different folders for which I have created a separate file containing path information called pathtofiles.in; /home/users/gray_wolf/unix/File_1.tsv ...
0
votes
1answer
60 views

Strange cut behavior

I'm using cut (GNU coreutils) 8.24. The command: echo "TEST=test" | cut -d"=" -f2- outputs Ttest. I don't think this is the intended behavior. Am I using it wrong or is there something wrong with my ...
0
votes
2answers
3k views

cut string on last delimiter

I have a filename like a.b.c.txt, I want this string to be split as string1=a.b.c string2=txt Basically I want to split filename and its extension. I used cut but it splits as a,b,c and txt. I ...
1
vote
3answers
133 views

how to break a line after matching a certain character using shell command?

File1: John Daniel Hommes Cameron;Emily Terry Mussy Barbara Mimi Papu;David Swiss Jen Hans Peter Iril;Kelvin Lilly Gucci Kate Nik;Forum Bill June;Jill and Jack Output file: John Daniel Hommes ...
0
votes
1answer
67 views

How to extract particular fields from lines using shell commands?

File1: 27/07/2014 10.10.03 Breaker1 was closed by Mr. A.Basu Spectrum ui6dms 29/07/2014 04.50.53 Breaker1 was opened by Mr. D.Gupta Spectrum ui6dms and one note added 30/08/2014 03.20.01 EarthSwitch ...
-1
votes
2answers
168 views

select portion of file by line interval [duplicate]

I want to practice using head, uniq and cut, for this data here. I know this thread but it focuses too much on cat and external programs. I would like a simpler answer. I want to take interval from ...
2
votes
1answer
48 views

How can I shorten strings shown in the i3status bar?

I am using the i3status bar. In the bar, I am displaying my wireless network details. However, space is limited and this takes up a whole lot of it. The standard format is defined in the i3status.conf ...
4
votes
5answers
775 views

How to cut a date/timestamp String?

So I am using TIMESTAMP=$( stat -c "%y" $JARNAME.jar ) print $TIMESTAMP and its output is something like 2015-04-24 17:23:03.000000000 -0500 I need only the 2015-04-24 17:23:03 part
5
votes
4answers
702 views

How to show only the last k columns in ls -l?

I like to restrict the columns shown in ls -l command, by eliminating the first 4 columns. ls -lh shows: drwxr-sr-x 20 gamma alpha 4.0K May 22 13:18 Desktop drwxr-sr-x 3 gamma alpha 22 Oct 6 ...
2
votes
2answers
243 views

Copy files with parent folder to a new directory

I want to copy some files and include their parent directory in the process. The current structure is similar to: /Module1/A/downloads/m13312/file.pdf /Module1/A/downloads/m17312/file.pdf ...
0
votes
1answer
177 views

Cutting logs (and not copying) from a log file between two time stamps

I have a very huge access.log file of 2 Gb containing apache access logs. The date time format in that is as below : 04/May/2015:02:15:25 I want to cut (and not just copy) the logs from this ...
1
vote
4answers
2k views

What the equivalent of “grep | cut” using sed or awk?

Say I had a config file /etc/emails.conf email1 = user@dinkum.dorg email2 = user@winkum.worg email3 = user@stinkum.storg and I wanted to get email2 I could do a: grep email2 /etc/emails.conf | ...
0
votes
3answers
63 views

Beginner Questions Regarding “<”, “<<”, and reading files

I know that I can do tr a b < file, but how do I do that for ls? So for example, How to feed ls -l a list of files from a 'file'. I tried the below and it did't work. $ cat>test A B C $ ls -l ...