Questions tagged [cut]

cut is a Unix command line utility which is used to extract sections from each line of input.

49 questions
8
votes
3 answers

How to echo only 1st line from 'curl' command output?

I'm trying to get only first line of the curl command output. (Sorry if this is confusing) Let's say, for an instance, i run simply: # curl http://localhost .. .. What…
夏期劇場
  • 700
  • 3
  • 8
  • 17
6
votes
2 answers

Black frames at beginning of video file when file cut

I use ffmpeg to cut a video file. The format i use is this: ffmpeg -i input.avi -ss 00:06:30 -to 00:07:15 -c copy output.avi Unfortunately this leaves some black frames in the beginning of my output video, so i lose certain parts of the video. In…
user1584421
  • 163
  • 1
  • 8
5
votes
1 answer

GNU sort and git blame

Today I thought I was doing a simple operation: git blame file | sort -k 3 To get all the lines of file sorted by the date on which they were last changed. Unfortunately it doesn't seem to be sorting it correctly. It does work if I do the…
Carl Norum
  • 2,353
  • 2
  • 21
  • 20
4
votes
2 answers

Bash command substitution not working as expected

I'd like to view the last few lines of a file, but I want the columns aligned. Basically, I want to disable wordwrap. This is straightforward with: tail $FILE | cut -c -80 But I'm trying to generalize my script for other users, and I'd like to cut…
Joe Fruchey
  • 155
  • 3
4
votes
0 answers

Is it possible to find piece of audio inside of mp3 file?

We have a community radio and we are recording all shows 24/7. And we are wondering is there any way to automatically trim those recordings so that all commercials and unwanted parts are cutted off and rest of the show is joined ex. 1hour .mp3 file?…
Godspeed
  • 41
  • 1
3
votes
1 answer

How to `cut` (extract a subset of columns) a CSV file that contains quoted strings`

I have a CSV file and want to discard a couple of columns. So let's say this is a sample file: column a, column b, column c value a, value b, value c value a, "quoted, b", value c And now let's say we would want to discard column b, so that the…
yankee
  • 673
  • 8
  • 18
2
votes
1 answer

Cut lies if delimeter doesn’t exist

For example: $ cut -d ' ' -f 2- <<< "example" example Why does cut lie to me telling me that “example” is the second delimeter and on. I want it to print "" since there is no second delimeter. Note this does the right thing: $ cut -d ' ' -f 2- <<<…
nullUser
  • 723
  • 1
  • 12
  • 30
2
votes
1 answer

Cutting out two parts from the middle of a video with ffmpeg

I have two files, rec.avi and audio_edited.wav, and what I'm trying to do is take the parts 00:30:50–01:42:56 and 02:16:55–04:03:10 of each file, concatenate those and encode them into an WebM file. My current command is partly copy-pasted from…
larsfu
  • 31
  • 5
2
votes
1 answer

How to Extract Multiple substrings from Log FIle

I am trying to extract the timestamp and the number string in the URL called in an apache logfile that looks like this: 123.456.78.90 - - [16/Dec/2014:06:27:30 +0100] "GET…
Unpossible
  • 133
  • 6
2
votes
1 answer

Inconsistent results using cut on output of ls

I am struggling to understand why I get different output from the same command run on a single file in Terminal (Mac OS X 10.6.8) and run on more than one file. As I want to run the command in a bash script I am trying to get consistent results when…
yvf5rcuya4
  • 23
  • 2
2
votes
3 answers

In bash, how do I pass the while loops input to the cut command?

How do I pass the $line to the cut command properly in this loop? while read line do login= $(cut -d : -f 1) done < /etc/passwd I can't do $(cut -d : -f 1 $line) so what is the correct way?
Mike
  • 1,427
  • 3
  • 11
  • 8
2
votes
1 answer

Add character at certain position in line

I've encountered the following problem: I need to add space at certain position in each line, to transform data from ATOM 1 HT1 GLY 5 10.346 30.927 130.252 0.00 0.00 to (by adding space in 12th column) ATOM 1 HT1 GLY 5 …
aland
  • 2,990
  • 16
  • 26
2
votes
1 answer

Move all the files and folders with CMD (BAT File)

I want to move all the files and folders inside the folder "C:\Foldertest\" into the folder "C:\Foldertest\target". And whenever I run this command, it does this for all files and folders except for the "C:\Foldertest\target" folder.
mohammad takin
  • 21
  • 1
  • 1
  • 2
2
votes
1 answer

Printing all columns after 5th with awk

I'm using this to filter a logging file and I'm trying to squeeze as much relevant detail as I can onto the console: awk -F " " '{$1=$2=$4=$5=$6=$7=""; print $0}' This is my raw input: 149.177.5.87 - [08/Feb/2017:18:14:20 +0000] 18:14:20:408…
Adam
  • 188
  • 1
  • 10
1
vote
1 answer

Error with command cut: the delimiter must be a single character

I am trying to run this command from console: # HTTPDUSER=`ps aux | grep -E '[a]pache|[h]ttpd|[_]www|[w]ww-data|[n]ginx' | grep -v root | head -1 | cut -d\ -f1` But got this error: Try `cut --help' for more information. I've tried the answer on…
ReynierPM
  • 363
  • 1
  • 5
  • 20
1
2 3 4