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

learn more… | top users | synonyms

2
votes
2answers
31 views

Get only the size of a mounted filesystem

I want to get only the total size of a mounted filesystem. But the catch is that I only know about the mount point. So, I thought of using the df command. To get the size of this mounted filesystem, ...
0
votes
1answer
38 views

How can I remove duplicate entries in linux log

I've turned mysql general log on and I've been logging every transaction that occurs for the last week. I also have a cronjob running every 5 minutes doing some mysql transactions which is polluting ...
0
votes
2answers
30 views

Generating strings of words with space delimiters from cut statement

I am new to bash. When I run the following command: grep "type" /root/myFile | cut-d'=' -f2 I get the following: 102 304 503 442 I want to store the contents of the first command into a ...
3
votes
3answers
39 views

awk to cut portion of a field and still print entire line

I have this line: 08:30:02.480507 IP 192.168.100.150.65119 > 192.168.100.151:53 59865 [1au] A? click.em.redbox.com. (48) I need to cut out the ".480507" in the timestamp so the line looks like ...
1
vote
3answers
60 views

How can I use a triple slash as a delimiter with cut?

I have a table in which each entry looks something like, coagulation factor VIII-associated 1 /// coagulation factor VIII-associated 2 /// coagulation factor VIII-associated 3 I would like to use ...
0
votes
2answers
35 views

Extract the second quoted string in a line of output

I have a line of output with three quotes, and I specifically need to extract the second quote into a variable. So for example, with the command cmd | grep tokens, I get the following output: Output ...
1
vote
4answers
36 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
36 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
45 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
58 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
37 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
30 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
53 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
46 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
50 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
120 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
46 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
99 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
89 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
39 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
83 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: <script>addRow("...
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
36 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
104 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). $ filename=./foo/bar/baz....
2
votes
2answers
101 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
70 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 Name2,...
1
vote
6answers
149 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
219 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
277 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
133 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
135 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: input....
0
votes
2answers
471 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
312 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
71 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 success,1234,["madhu",{'first',[{'last',18}]},"I0"...
0
votes
2answers
75 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
183 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: root@...
1
vote
1answer
70 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
1k views

Bash to join columns from multiple files

I have around 20 files in different folders for which I have created a separate file called pathtofiles.in which lists path information: /home/users/gray_wolf/unix/File_1.tsv /home/users/gray_wolf/...
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
4k 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
142 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
69 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
177 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
49 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 ...