Skip to main content

All Questions

Tagged with
0 votes
1 answer
91 views

How to get the return value of pipe and executable on Windows

I am running some unit tests which involve piping into my executable, like this. cat text.txt | my_exe --options Running these commands, how do I get the return value of my_exe? Even when my_exe ...
scx's user avatar
  • 183
0 votes
1 answer
93 views

Concatenate pairs of mp3 files with ffmpeg or cat?

I've got a directory of mp3 files, which look a little like this: Blue Elephant part 1.mp3 Blue Elephant part 2.mp3 Tale of Two Cities part 1.mp3 Tale of Two Cities part 2.mp3 Lookism part 1.mp3 ...
cannyboy's user avatar
1 vote
1 answer
16k views

cat command with a variable that has spaces

I need to use cat command to display the contents of a file, and the filename has spaces in them: "embedded board link.rtf". I assign the filename using a variable: I="embedded board link.rtf", but ...
prosseek's user avatar
  • 5,974
7 votes
7 answers
10k views

What is the equivalent of Bash's cat -n in PowerShell?

I want to cat a file and output the line number of each line it outputs. However, in PowerShell, cat outputs an array. Hence the question effectively becomes: How do I print the index of each item ...
deostroll's user avatar
  • 1,815
0 votes
2 answers
2k views

What's the behaviour of `cat | less`?

I tried to run the following command: cat | less I know both commands require something from the standard input. When I run it that's what I expected: all my inputs goes to cat and I will not be ...
user1833218's user avatar
0 votes
1 answer
643 views

Piping a line of the file read with while read loop

I am trying to read each line of the file and then assign some parts of it to variables. A line itself is read as a variable so I need to process a variable input say for cat which seems to be ...
Jargal's user avatar
  • 1
2 votes
2 answers
4k views

linux cat into file including exiting code all from copy+paste

Can I print out a code to STDOUT that would mimic the behavior of Ctrl+c inside cat? E.g. I would like my script to print out the cat command followed by the content of the file like this: cat > /...
719016's user avatar
  • 4,457
0 votes
2 answers
2k views

Execute a command for 3 lines at a time

I'm trying to run three separate processed while reading foo.txt Here is the example: cat foo.txt | while read line do echo line1 echo line2 echo line3 echo "" done The expected output is: line1 ...
Niresh's user avatar
  • 233
0 votes
1 answer
732 views

How to print statistics from lines in a file

I often find myself computing percentages manually after filtering through a log file to find the proportion of X or Y in it. Can this easily be achieved via common CLI tools?
Seldaek's user avatar
  • 135
0 votes
2 answers
3k views

Copying a template header to multiple existing files

I have a bunch of *.csv files that use headers. Right now the files have headers and the same number of lines of data. I need to erase the data in these files, so I figured I could just overwrite the ...
Stuart's user avatar
  • 407
14 votes
4 answers
42k views

How can I stop cat output immediately despite massive output?

I'm looking for someway to stop the output to STDOUT when I realize a command is wrong. For instance, if I accidentally cat a very large file. Usually it will eventually stop if you hold down ctrl + c,...
CHK's user avatar
  • 587
21 votes
7 answers
15k views

Cat file to terminal at particular speed of lines per second

I'm lazy and I could write a script to do this, but I'm even too lazy to think of how to do it. I often do things like : cris$ python runexperiment.py > output.txt cris$ cat output.txt ...
Cris Stringfellow's user avatar
1 vote
1 answer
249 views

Pass an option syntax string as filename

I somehow got a file named --no-recursion in a directory. How can I get cat to show what it contains? Not like this, since the argument gets interpreted as an option: root@nagini [/home/lalilulelo]# ...
Bart van Heukelom's user avatar
5 votes
5 answers
16k views

Concatenating files from multiple subdirectories

Say I have a directory structure that looks like this: file1.txt folder1/ file2.txt folder2/ file3.txt How can I concatenate file1.txt, file2.txt, and file3.txt into a single file? Edit: ...
Joe Mornin's user avatar
  • 1,667
51 votes
8 answers
13k views

What is the general consensus on "Useless use of cat"?

When I pipe multiple unix commands such as grep, sed, tr etc. I tend to specify the input file that is being processed using cat. So something like cat file | grep ... | awk ... | sed ... . But ...
arunkumar's user avatar
  • 623

15 30 50 per page