Skip to main content

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.

1 vote
1 answer
28 views

How do I format the output of cut to the following format? [duplicate]

last part of the command: | cut -d' ' -f3 output: 4 10 required format: 4,10 I'm guessing echo (and sort?) is to be used in some way, but I can't quite place my finger on it.
kesarling's user avatar
  • 159
1 vote
0 answers
33 views

pfSense (FreeBSD) - tail -f not showing entire log when filtering with cut or sed [duplicate]

I have a strange problem when trying to display logs on pfSense (and I can reproduce the same problem on Ubuntu server also). The problem is this (with examples): I'm trying to display a running dhcp ...
Artur Meinild's user avatar
0 votes
2 answers
51 views

Unexpected cut output

I am getting an unexpected output from cut. I would expect no output since there is no third field based on the specified delimiter. The first two lines intentionally use commas as delimiters, and the ...
ayeieye's user avatar
0 votes
1 answer
62 views

cut -d – Delimiter is still shown in the output. How to remove it simply?

Why the delimiter is still shown in the output? I thought field 2 and 4 would be shown without the - delimiter. How to use cut command to not show at the same time the delimiter itself used to ...
Faxopita's user avatar
  • 179
0 votes
3 answers
93 views

How do I change the extension of a long filename quickly?

original file: a really really long name with spaces.ext target file: the same name.new-ext command: mv *part of the name that'll give a unique answer.ext $(echo $(ls -l | grep -i *.ext | cut -d ' ' -...
kesarling's user avatar
  • 159
4 votes
1 answer
425 views

Cut command stored in variable will not work

Can someone explain why I cannot store the cut command in a variable?? user:~$ echo "foo bii doo" | cut -d ' ' -f 2 bii # as expected # now put cut command into a variable: user:~$ c="...
archygriswald's user avatar
-1 votes
2 answers
136 views

Grep a log file for SQL queries and their execution time

I have an application log file that also captures the execution time for each executed SQL statement, like below:- Sample logs: I 2023-11-15 07:18:00.743Z 1760463 37 ZVRwqItu6aw-b8eejMLI_gAAAAU 1@...
Arpit Jain's user avatar
1 vote
4 answers
344 views

Retrieve the 1st and 5th column of a tab-separated file, convert the spaces in the 5th to tabs

I have a tsv file with tab-separated columns. I want to obtain the 5th column, which has space-separated values. Convert the space-separation to tab-separation and save as a new file. Attempt: cut -d&...
Anon's user avatar
  • 133
2 votes
2 answers
266 views

A shorter way to list all packages matching a string

When I search for a list of packages, I usually use dpkg -l|grep string|cut -d" " -f3|xargs libdouble-conversion3:amd64 libestr0:amd64 libeval-closure-perl libio-stringy-perl libunistring2:...
rubo77's user avatar
  • 29.4k
0 votes
2 answers
130 views

How to combine tr with xargs and cut to squeeze repeats

The top answer to this question demonstrates that cut can be used with tr to cut based on repeated spaces with < file tr -s ' ' | cut -d ' ' -f 8 I want to get the remotes of several Git repos in ...
Anil's user avatar
  • 221
1 vote
2 answers
90 views

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: ...
Chris's user avatar
  • 983
0 votes
3 answers
339 views

listing existing users sorted by date of creation using cut command

ASK: to use cut command to list all users to confirm a successful useradd. ISSUE: The list was very long and I had to scroll through output to find user. NEED: Sort by the date the user was created. ...
VintageDroid's user avatar
0 votes
0 answers
37 views

Truncate output to terminal width (colour and wide char aware) [duplicate]

I have the alias: trunc='cut -c -${COLUMNS:-80}' This works just dandy when text doesn't contain colours and wide characters. I could play with tput rmam and tput smam, but these don't actually ...
Tom Hale's user avatar
  • 31.2k
2 votes
4 answers
390 views

linux command using trim / cut / sed to cut few data in a file

I have the content like below in a /tmp/myfileslist test1/a/sample1.xls test2/demo.sh I want to remove .extentions and content before slash , also slash is to be removed.I want the output as sample1 ...
afrin's user avatar
  • 61
1 vote
4 answers
72 views

Extract substring between n and m delimiter

I want to write a for loop to obtain everything between the third / to the 4th . for a list of files. My attempt: for mcool_file in ./input/*.mcool; do while IFS= read -r id; do id | cut -...
Anon's user avatar
  • 133

15 30 50 per page
1
2 3 4 5
30