Turing101
Turing101

Reputation: 377

Store the output of grep command in a file

I have a scp file that contains the paths to the various audio files. Say the scp file is file.wav.scp and it contains these paths

/home/red/audio1.wav
/home/blue/audio2.wav
/home/red/audio3.wav
/home/blue/audio4.wav
/home/blue/audio5.wav

I am using the grep "blue" file.wav.scp to find the paths which has the blue keyword in it. Now is there any way to store these outputs in a file directly from grep's output?

Upvotes: 0

Views: 81

Answers (3)

Gereon
Gereon

Reputation: 17844

Use grep "blue" file.wav.scp >outputfile.

This is called I/O redirection and is an essential concept in shell usage and programming.

Upvotes: 1

Rob
Rob

Reputation: 11788

Sure:

grep "blue" file.wav.scp > filename.txt

Upvotes: 1

kiner_shah
kiner_shah

Reputation: 4641

Try:

grep "blue" file.wav.scp > blue_file_paths.txt

Upvotes: 1

Related Questions