Questions tagged [cut]

For questions pertaining to cut, a filter program which extracts fields or columns of each line of input. Use this tag for questions about cut itself or questions about issues arising from using the cut utility.

The tag should be used for questions that are about the utility itself or about issues arising from the usage of the utility.

Relevant questions

How to define 'tab' delimiter with 'cut' in BASH?

Split string by delimiter and get N-th element

External reference

cut specification (The Open Group Base Specifications Issue 7, 2018 edition)

446 questions
6
votes
1 answer

Does cut return any fields if separator does not exist

I executed cut -d '~' -f 2 on input RSC AED FCB A~RS and I obtained RSC AED FCB RS I realized that cut will return entire line if the delimiter does not exist. It is that true?
nucandrei
  • 195
4
votes
6 answers

cut command, order not preserved?

I have a sample file:- [root@localhost base_filters]# cat shortlist 2233|charles harris |g.m. |sales |12/12/52| 90000 9876|bill johnson |director |production|03/12/50|130000 5678|robert dylan |d.g.m. |marketing |04/19/43|…
Ankit
  • 1,385
4
votes
2 answers

Can you specify an enclosure for cut?

Possible Duplicate: Is there a robust command line tool for processing csv files? I can use cut to extract columns from a file: $ cat foo foo,bar,hello bash,baz,world $ cut -d\, -f2 foo bar baz But what if a column has a delimiter in it that is…
Cory Klein
  • 18,911
4
votes
1 answer

Linux cut command with -f1

What is the meaning of the following command: cut -d" " -f1 I found out what cut -d" " means: removing spaces, right? but what means this -f1?
user97250
  • 61
  • 1
  • 1
  • 3
2
votes
2 answers

How to cut file name not actual file

I have a list of file names like ./run_results/rat/coding_exons/0.01_100_best.txt ./run_results/mouse/introns/0.01_100_best.txt I want to create new files with names like rat_coding_exons_0.01_100_best.txt or…
2
votes
3 answers

Does delimiter parameter on cut command, always expects it to be in between a string?

I noticed something with the cut command today, which somehow I had never noticed before, even though I have been using and working with them for a long time. From string /users/developer/, I wanted to extract users. So, what I did was, echo `pwd` |…
Incognito
  • 376
2
votes
1 answer

cut: option requires an argument -- 'f'

I'm having trouble how to through this step for my homework. I insert the command: tail -n +2 ../data/Pacifici2013_data.csv | cut -d ’;’ -f and the output comes out saying that cut: option requires an argument -- 'f' I have no idea how to proceed…
1
vote
2 answers

How do I backslash-ignore a delimiter passed into cut?

I have the following use case: echo "some comment char '\;' embedded in strings ; along with inline comments" \ | cut -d';' -f 1 I want: some comment char ';' embedded in strings I get: some comment char ' How do I hide the delimiter…
Chris
  • 961
  • 7
  • 20
1
vote
3 answers

How to use cut to get the last field of /proc/pid/maps?

I need to do some processing on the list of .so loaded by a process. I tried cut with space as a delimiter but I didn't succeed. How to correctly pipe the output of cat /proc/PID/maps into cut to get the last field ?
boredaf
  • 181
1
vote
0 answers

Cut specific lines of file?

I have a 100 line text file. I want to extract lines 50 to 70 inclusive. How can I do this? My Google skills are failing me and man cut doesn't seem to have the answer - perhaps I need a different tool.
Richard
  • 3,463
1
vote
2 answers

How to cut a string based on delimiter which is having space

variable_list=" any:any:-a -b -c any one:one:-c -b -f -m mul mul:one:-c -b -f -m mul " for f in `echo $variable_list` do c1=`echo $f | cut -d':' -f1`; c2=`echo $f | cut -d':' -f2`; c3=`echo $f | cut -d':' -f3-`; echo "c1==>$c1 and…
RBB
  • 1,009
1
vote
1 answer

How to cut specific number without cut all numbers

F gge0006y D 12-30-2006 T 14:05:55 S a69 B 15.3 M gge06001 P 30.6 Q 21.1 R 1006.6 U 1014.6 X 36.1 A 38.994 0 0 G 107.71 0 0 H 8.433 O 36.705 C 7.621 K 27.623 W 210.51 I need to cut the both 0 …
1
vote
2 answers

How to remove the second column of a .txt file?

I am working on a .txt file which is the output of a neuroscience program called fsl. It does have 2 column and I want to remove the second one, I test some of the suggested codes but it seems like the Linux commands couldn't separate the two…
1
vote
2 answers

cut out specific fields from text file

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
riley
  • 351
1
vote
1 answer

Cut one line on two

I want to delete one line on two with linux such that A B C D E becomes A D E how can I make it work?
1
2