Questions tagged [cat]

A UNIX utility for concatenating files or input streams together. Do not use for questions about the animal.

Filter by
Sorted by
Tagged with
0 votes
1 answer
994 views

Tar & save the output of a command

I want to tar the output of a command, say cat hello.world, to a compressed tar file. I don’t want to save a temporary file and later tar it manually. How can I do this?
ather05's user avatar
0 votes
2 answers
2k views

Recover text file that I deleted with "cat" command

I used cat > filename while not thinking about it, then hit ctrl + c and naturally enough the file is now empty... Is there a way to recover that file's contents?
Not Amused's user avatar
-1 votes
3 answers
200 views

How to use the command "read" on a Shell script which reads its arguments from stdin

First of all, thank you for your help in advance and sorry in case this was answered before. I have not been able to find it. For helping to understand my question, I have written the following ...
Lucas's user avatar
  • 1
1 vote
1 answer
4k views

To print values in diferent line in mail body shell script

Below is the code to print contents of files present in the directory File contents are : apple banana grapes mango names=() FILES=/path_to_dir/* for f in $FILES do names+=($f) done ...
user's user avatar
  • 199
2 votes
1 answer
16k views

Receiving data from Serial Port

I want to receive data from RS232 Serial port to my terminal and with a directive to a file. It should be pretty straight forward. cat /dev/ttyS0 cat /dev/ttyS0 > file.txt Before that I've ...
Swami Moksha's user avatar
1 vote
0 answers
75 views

Cat playing with mouse broke my Windows/Explorer :( Cannot click buttons in most of standard apps/menus

My mouse was laying on a sofa (I was going to clean it a bit) and my cat suddenly decided to play with the mouse (while the start menu was opened). Nothing serious happened with it during these 10 ...
AlexP11223's user avatar
-1 votes
1 answer
168 views

Using wildcards with cat append target

I need to append the contents of two files to a third, where I don't know the exact file name of the target. Let's say it's named targetXXXXX where XXXXX is a random string. I am basically trying to ...
Toby Nieboer's user avatar
20 votes
2 answers
58k views

pipe and stdin redirection to cat

Why does echo "hello world" | cat works while cat < echo "hello world" does not? My (incorrect) intuition is that pipe would redirect stdout to cat as stdin.
irritable_phd_syndrome's user avatar
0 votes
2 answers
44 views

shell - multiple text insertion into each line of a file

I have a text containing coordinates of points such as x, y and z, I would like to change each line to be like: Point{ (1000+linenumber) } = {x , y, z}; What I want is: for example for line 212 ...
user2090491's user avatar
0 votes
1 answer
302 views

/usr/bin/mail not interpreting new lines

I have a strange problem when piping a cat to mail. I have a simple text file which has been compiled from a script, which is a report on what folders were copied in the script. I then want to send ...
Andy Foster's user avatar
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
1 vote
3 answers
4k views

add new line after every end of file's contents while merging multiple files

I have written shell script to merge different file's contents I have created directories f1,f2,d1,d2 and files under them , I need to merge all files's contents : comand is (find /home/ah5024331/f1 ...
user's user avatar
  • 199
1 vote
1 answer
175 views

Empty line appears while merging different file contents in shell script

I have written shell script to merge different file's contents I have created directories f1,f2,d1,d2 and files under them , I need to merge all files's contents : comand is find /home/ah5024331/f1 /...
user's user avatar
  • 199
0 votes
1 answer
617 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
0 votes
2 answers
1k views

How to merge multiple files into single file in given directories

I want to write a shell script to merge contents of multiple files in a given directories. DIR1 contains sample1.txt sample2.txt sample1.txt contents :---this is sample1 file--- sample2.txt ...
user's user avatar
  • 199
0 votes
0 answers
1k views

cat > $FILE_NAME << EOF - Explanation of the inner workings

I know what this one does, I learned "pattern like" and just works. I also know: that > is a redirect to a file that << is also a redirect to file see below EOF is just a placeholder, when ...
Ely's user avatar
  • 169
33 votes
3 answers
46k views

Using -replace on pipes in powershell

I want to test out a replace before I use it, so I'm trying to write a quick online command to see what the output is. However, I'm not sure what the syntax is. What I want to do is something like ...
David says Reinstate Monica's user avatar
0 votes
0 answers
556 views

How to uninstall screen (monitor / display) drivers?

While testing out some different computer screens (also called displays or monitors) on a Windows 7 SP1 system, I installed the .INF files for each screen. I also installed the .ICM (color matching ...
End Anti-Semitic Hate's user avatar
3 votes
4 answers
2k views

Prevent cat from opening a binary file

Is there a way to prevent or prompt you when trying to cat binary files? Oftentimes I need to work with log files or data files, some of which are text and others not. It's easy to get mixed up, and ...
bobdole's user avatar
  • 63
1 vote
2 answers
645 views

Is cat output modified by writing to the file

With a piped command sequence like: $ cat afile | somecommand | tee afile afile is both read (by cat) and written (by tee). The question is, supposing afile is at least several megabytes (or large ...
adelphus's user avatar
  • 240
0 votes
2 answers
90 views

Combine the results of a CAT and TAC in a single window in Linux

I have two log files which I would like to view on my screen simultaneously. Below you can see my commands: pi@raspberrypi ~ $ watch -n 1 tac /home/pi/log/log.txt pi@raspberrypi ~ $ watch -n 1 cat /...
user avatar
17 votes
2 answers
5k views

lossless concatenation of ogg vorbis files

I have a couple of ogg vorbis files, all encoded with the exact same properties that I want to concatenate into a single file. I know that the ogg vorbis format supports plain concatenation of ...
josch's user avatar
  • 887
0 votes
0 answers
146 views

Unix cat to Windows user

I uploaded about 6GB of video in 3 separate files created using the cat command on my Mac, thinking the recipient of those files was a Mac user as well. It turns out he's using Windows 8. How can he ...
dave_d'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,347
0 votes
2 answers
154 views

how to clone a directory list to another directory

I am trying clone a directory and it's subdirectories into another directory. I have hundreds of music directories with sub-directories that I want to convert from flac to ogg. I want all the music ...
Widgeteye The Terrible's user avatar
1 vote
2 answers
523 views

Make a web request, cat response to stdout?

I'm working from the command line. I need to cat the response of a web request. What tool can I use to make the web request and print the response on stdout? Here's the command I'm trying to make ...
jww's user avatar
  • 12.1k
2 votes
2 answers
1k views

Trying to cat the result of piped commands

I have a folder of files that are named list20140801.txt list20140802.txt .... I'm trying to do this ls | sort | tail -3 | cat But it is just giving me the file names, not cat'ing them.
Colton's user avatar
  • 21
0 votes
1 answer
166 views

Sort piped to uniq unexpected output

I have a file that looks like this: "string",192.168.1.0,,TX,192.168.1.2,,,100,0,0,10,10,10,, "string",192.168.1.0,,TX,192.168.1.1,,,100,0,0,10,10,10,, "string",192.168.1.0,,TX,192.168.1.4,,,100,0,0,...
trueCamelType's user avatar
1 vote
2 answers
787 views

Adding text to the end of multiple files, minus one line( Adding return 0; at the end of each program in C)

I have a bunch of C programs from K&R and of course, no return statement. I was wondering if there was a way to cat to the end of each file (except one line before the end, so EOF - 1) the ...
user339365's user avatar
7 votes
2 answers
7k views

cat wc -l count lines line with defined line endings (e.g Mac OS X specific)

As any command-line user I sometimes want to count lines in text file with well known command: cat some_text_file | wc -l I face the problem on Mac OS X, which as far I have it studied is connected ...
andilabs's user avatar
  • 561
39 votes
4 answers
55k views

Change Behavior of Linux Power Button

I have a headless linux mint machine that I use for a file server and other things. It's been working great for me for a few years, but there's one issue - my cat likes to hang out on top of it, and ...
schizodactyl's user avatar
1 vote
1 answer
2k views

head and cat don't recognize Microsoft Excel text files

I have a large .xls file with 53760 rows and 19 columns. I saved it as Tab Delimited Text in order to pre-process it through command line tools and load it into R later. However, when I run head ...
Marcus Nunes's user avatar
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
6 votes
1 answer
6k views

Can cat be used to clone a partition?

For example, can I do: cat /dev/sda1 > /dev/sda2 instead of using dd, and if not, why will this not work?
Grezzo's user avatar
  • 962
1 vote
3 answers
2k views

Move multiple files from filename list to a new folder

I have a list of filename in list.txt, which have 'abc1.png, abc2.png, abc3.png....'. However, I don't know the directories where the files are. I want to find all files in the txt file, and move ...
user279816's user avatar
0 votes
0 answers
159 views

Special and diacritic charactres using less, cat and other linux tools

I am using GNU bash, Version 4.1.10(4)-release (i686-pc-cygwin) and set up my .inputrc to allow for special characters and German umlauts etc.: set meta-flag on set convert-meta off set output-meta ...
Oliver's user avatar
  • 171
0 votes
1 answer
723 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
3 votes
2 answers
2k views

Why did my bash prompt turn to gibberish after I accidentally ran `cat` on a .coverage file?

I had just installed coverage and run it a few times when I noticed a .coverage file hanging around in my repo, which is -- according to the file utility -- a 8086 relocatable (Microsoft) file. And ...
3cheesewheel's user avatar
0 votes
1 answer
874 views

Why does echo work through pipe but not cat with msmtp?

This works: echo "yada yada" | msmtp [email protected] but not this: cat yadayada.txt | msmtp [email protected] which delivers the email with empty content. Why does echo work through pipe but not cat ...
user19496's user avatar
  • 1,490
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
41k 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
6 votes
4 answers
3k views

Is there anyway to `cat` two remote `tail -f` streams via SSH?

I wanted to combine two continuous text streams generated by tail -f into one and watch them in the same screen. Is it possible? Both text streams are line-oriented (e.g. logs), if that helps. ...
Riobard's user avatar
  • 474
10 votes
5 answers
72k views

Cannot cat file which has space in name in linux

I believe there's a simple fix but cannot debug it out. I have file called "file name with space" How do I cat this file from Linux bash ?
Maulzey's user avatar
  • 251
0 votes
2 answers
3k views

How can I simplify this command in Linux consisting of cat piped to a grep?

How can I simplify this command in Linux consisting of cat piped to a grep. cat foo*.txt | grep cow I was told that this is the wrong way to do this. Why is that?
Belmark Caday's user avatar
20 votes
7 answers
69k views

how to copy entire linux root filesystem to new hard drive on with ssh and tar

I need to transfer an entire linux root filesystem off of a failing hard drive onto another computer with an open, available partition. I've pretty sure this involves tar and ssh, but I can't remember ...
CHK's user avatar
  • 587
0 votes
1 answer
471 views

Write output to $TMPDIR/$variable : file does not exist (should be created)

I have the following .sh script in which I am trying to do all major writing in $TMPDIR. However, when it gets to line 86, it returns the following error: /var/spool/uge/bnbhimem2/job_scripts/855849:...
Carmen Sandoval's user avatar
3 votes
1 answer
3k views

How to prepend contents of a file to another

This question relates to the already asked question How to add text to beginning of file The answer suggested by Dennis Williamson does the job: echo 'task goes here' | cat - todo.txt > temp &...
detraveller's user avatar
0 votes
1 answer
328 views

cat command outputs the whole directory when used in a bash script

I have a scirpt like this: #!/bash/bin file=`cat /proc/net/arp` echo $file And when I run the script it outputs the whole folder where the script is like this: IP address HW type Flags HW address ...
Kajzer's user avatar
  • 121
0 votes
1 answer
907 views

Combining multiple data files with header while also adding a data column

I have multiple tab delimited data files that are separated by month in the format jan06.txt, feb06.txt, ..., dec07.txt. Within each file, it looks something like: Header1 Header2 Header3 ... Data1 ...
user1027169's user avatar
10 votes
5 answers
32k views

How to display the file contents recursively?

I always have to submit the source codes in my printed assignment report. I have to copy and paste my course codes into the document and I find that it is an annoying task. I want to solve this "copy ...
user1022209's user avatar