cat is a Unix utility used for concatenating files.

learn more… | top users | synonyms

0
votes
3answers
38 views

Find the row and append to the bottom of the file

I have a big file with some record which will be having different values than others. Actual data file: 000000106500000000000129201300000U1E4600000060000+00000020400+00000002532+000000 ...
1
vote
2answers
84 views

cat < file.txt Who is the responsible of reading the file?

cat < file.txt Who is the responsible of reading the file ? Is the shell reads the open and read the file then write its content to the standard input of the command ?
2
votes
1answer
29 views

Printing from a FIFO pipe without interfering?

I have a couple of C programs sending messages back and forth through FIFO named pipes in Unix, and I want to see what's going through the pipes using an external program. The problem is that if I use ...
0
votes
1answer
29 views

How to terminate cat command within a shell script

I wrote a shell script that uses cat and tr commands to generate a file. My shell script looks like #!/bin/bash printf "generating random file > plaintext \n" cat -v | tr "a-z" "b-y" < ...
2
votes
2answers
53 views

cat command in shell does not terminate on receving EOT through serial port

I have shell/perl script which kicks off cat commands to receive incoming serial data from n external device. The external device is designed to send to send a EOT character when it's done ...
3
votes
4answers
316 views

How to cat two heredocs? [duplicate]

When cat is given two heredocs, it only outputs the second one. $ cat <<HERE > adsf > qwer > HERE adsf qwer $ cat <<HERE <<ALT > qwer > asdf > HERE > zxcv > ...
2
votes
0answers
59 views

cat /dev/ttyS0 Input/output error

I created infrared receiver as in LIRC manual (http://www.lirc.org/receivers.html). And tested it on windows using program called Terminal. When I switched on RTS pin DCD pin was also switched on ...
0
votes
1answer
44 views

What is the logic behind the expression cat > foo << “wordofchoice” [duplicate]

I know the > and >> operators, > puts something into a file by deleting the old content, >> appends something onto the end of the file's content. When I only use cat > foo I am able to write ...
3
votes
2answers
149 views

Meaning of `cat /dev/null > file`

In a document created by a former coworker there is this command: cat /dev/null > /var/spool/mail/root It says next to it that it will clean out mailbox. Can someone please explain how/why ...
1
vote
3answers
204 views

A sort of reversed cat [closed]

I've two documents that are the result of SQL Queries. For exemple i've my Doc1.lst that is : John1 0 Julien 10 Jules3 0 Julie 30 On this Doc1.lst, I used sed to have only ...
1
vote
1answer
40 views

What happens when I cat a non-text file?

When I run cat on a file that isn't just text it returns a large amount of characters (many of which look like this ���). What is this data?
4
votes
3answers
219 views

How to read dash files

How can I read a dash file from the terminal other than delimiting it with ./ For example to read a - file we can read it by cat ./-file_name Q: Is there an alternative way to achieve the same ...
1
vote
1answer
18 views

file (vdi) increase (at double) size after split and then cat operation

I'd splitted a vdi file with 7 gigabytes and then joined with cat command. The file works normally on VBox, but get 14 gigabytes after be re-joined. The exact operation was: $ split -- bytes=2000M ...
2
votes
1answer
56 views

attempting to put dynamic input data in a variable via cat method

I'm attempting to write a bash script that should be able to collect data from ttyS0 and put in a variable. I need to talk with a device on the serial line, that is a module able to receive AT ...
-2
votes
1answer
49 views

Understanding of a Batch

I need your help to check if my understanding of those lines are correct. As a rookie in Unix, I work step by step. if [ $? -ne 0 ]; then I didn't find any correct explanations about the -ne but I ...
0
votes
3answers
49 views

Reuse output from command 1 in command 2 using a pipe

I've got a command in linux which returns a list of numbers. Now I need this numbers to form a directory path and cat the file located at that path. For example: myCommand returns: 1 10 30 40 And ...
4
votes
2answers
100 views

Characters visible in vi, but not in cat.

I have a 300 lines file with ^@ character between each characters in the file. (I cannot post the entire contents for security reasons, so I am pasting only the first line) [mercury@app01 ftp_logs]$ ...
0
votes
1answer
170 views

How to assign the cat output of a bash script to a variable in another script

I have a bash script that produces a cat output when it takes an argument. I also have another bash script that executes the first bash script with an an argument that I want to produce cat outputs ...
3
votes
1answer
134 views

Mac OS X combine cp and cat to sequentially copy and rename files in list

I am using a MacBook Pro OS X 2013 model. I have a list of filenames in a text file named list.txt separated by line breaks list.txt exactly like this, but this list is going to be long e.jpeg ...
0
votes
1answer
48 views

How could I include a variable in a here document?

I am trying to use a user-defined global variable in a cat <<eof>> filename situation, but it's not working. I found what I want in simple cat << eof examples on this forum, which ...
0
votes
3answers
301 views

How to concatenate a variable number of csv, removing their header rows?

I have a directory with several hundred csv files whose filenames start with two digits {01..84}. Several hundred >> 84, so obviously some filenames start with the same prefix. I wish to concatenate ...
1
vote
2answers
74 views

Multiple arguments using xargs.

I know xargs can take many arguments like so. xargs -n5 -I{} echo {} but how do I put the arguments in a particular location I want do something like. xargs -n5 -I{} curl ...
1
vote
2answers
86 views

Stdin Input Behavior Between “cat” and “less”

When I issue cat, the terminal hangs waiting for stdin input. However, when less is issued, I get Missing filename ("less --help" for help). It is known that both less and cat accepts stdin input. ...
12
votes
2answers
936 views

Ctrl+D for ending terminal line input

If I do $cat > file.txt text<Ctrl+D><Ctrl+D> Question1: If I don't press enter, why do I have to press Ctrl+D twice? If I do $cat > file.txt pa bam pshhh<Ctrl+Z> [2]+ ...
97
votes
7answers
12k views

How to kill a runaway cat?

Many times I accidentally run the cat command on files that have contents up to few thousand lines. I try to kill the cat command with Ctrl+ C or Ctrl+Z, but both only take effect after the total ...
0
votes
1answer
187 views

Command that prints file contents given filename on stdin

I have a command that produces some output part of which is actually a file name containing the full output data. I want to extract the file name (which I trivially do with cut) and then pass it to ...
0
votes
5answers
61 views

Is there a way to do a “full file buffering” inside a chain of piped commands?

Very often I do simple operations on a file, for example: cat file1.txt|sed -r 's/^ *//' to remove spaces at the beginning of the line. If I want to overwrite the file, the only way I know is: cat ...
2
votes
3answers
152 views

How to sort filenames with spaces in them and concatenate the files?

I have the misfortune of dealing with filenames that contain spaces. I want to concatenate files of which filenames contain spaces. I also want to sort the filenames numerically. Obviously the ...
3
votes
2answers
192 views

Less resource hungry alternative for piping `cat` into gzip for huge files

I have some files of which some are very large (like several GB), which I need to concatenate to one big file and then zip it, so something like this: cat file1 file2 file3 file4 | gzip > ...
3
votes
6answers
2k views

get first X characters from the cat command?

I have a text file I'm outputting to a variable in my shell script. I only need the first 50 characters however. I've tried using cat ${filename} cut -c1-50 but I'm getting far more than the first ...
0
votes
2answers
65 views

Cannot merge files using cat [duplicate]

I tried to open a lot of files (10,000+) with cat and them merging them into one like this: cat * > ~/Desktop/lol.xml But it returned this error: -bash: /bin/cat: Argument list too long This ...
2
votes
1answer
329 views

splitting a CSV and keeping the header without intermediate files [closed]

I am trying to split a dozen 100MB+ csv files into managable smaller files for a curl post. I have managed to do it but with a lot of temporary files and IO. It's taking an eternity. I am hoping ...
3
votes
1answer
422 views

grep not working in a for loop over a list

I have some log files. And I have a list of user ids. My log files are in a particular format log-yyyy-mm-dd e.g. log-2014-09-30 I am trying to search each userId in the log file. This is what I am ...
0
votes
1answer
157 views

reading file using for, while - behavior

Consider the below scenario 2 vms - 192.168.229.131, 192.168.229.132 Both the vms has it's ip as 192.168.229.151 & 192.168.229.152 in it's /etc/hosts file Say there are around 50 vms like i ...
3
votes
2answers
2k views

How to concatenate two files in a new one and sort the output in one line

I have two files with some names in them, when I ran cat file1 file2 | sort, the terminal shows the names sorted alphabetically, but when I run cat file1 file2 > file3 | sort I don't see the sorted ...
2
votes
2answers
90 views

Joining files with cat confusion

If I do the following commands: $ cat picture.jpg > copy1.jpg and $ cat -v picture.jpg > copy2.jpg copy1.jpg is a perfect copy of picture.jpg, but copy2.jpg is a lot bigger than ...
0
votes
2answers
371 views

How to combine gunzipped fastq files?

How can I combine gzipped fastq files? I tried this for read 1 and read 2 zcat file_1.fastq.gz file_2.fastq.gz | gzip > combined.fastq.gz but it is giving me unequal number of reads. Why? Is ...
1
vote
2answers
256 views

Concatenate file contents AND names

I've been writing for many months. The files I create are dated files named like 2011-06-13.markdown with daily content. I've decided I want to have all the writing in one file instead but I'd like ...
2
votes
1answer
71 views

top not showing the memory usage of cat

I wanted to generate some waste file of 50 GB. so i wrote this eightnoteight@mr:~/ while true; do > cat txt >> tmp > cat tmp >> txt > done and when i ran top,watch to observe. ...
0
votes
2answers
44 views

Are `less textfile | col` and `cat textfile` the same?

Do less textfile | col and cat textfile accomplish the same thing? I wonder if man mysql | col -b > textfile and man mysql > textfile do the same?
11
votes
2answers
287 views

Why does cat x >> x loop?

The following bash commands go into an infinte loop: $ echo hi > x $ cat x >> x I can guess that cat continues to read from x after it has started writing to stdout. What is confusing, ...
5
votes
6answers
2k views

Command to output file content to stdout?

I know cat can do this, but its main purpose is to concatenate rather than just displaying the content. I also know about less and more, but I'm looking for something simple (not a pager) that just ...
1
vote
1answer
250 views

What does this `cat` statement do?

I'm new to Linux and trying to figure out what this statement in a Bash file does. I think it combines stdout, stderr and output it to the file $log is pointing to and append the multiline string to ...
0
votes
1answer
31 views

find file read it and search for specific identifier

I'm trying to find out in what files some specific identifiers are being used. I know the file's name and know the identifier, therefore I use the following command to achieve my desired result: find ...
1
vote
2answers
87 views

cat combining not all file formats - but which ones?

In GNU⁄Linux, combining files with cat works in miraculous ways – at least for me: cat part_* > /destination/file.xyz with the same file format for BOTH source and target file(s) ...
1
vote
0answers
33 views

Edit a command? [duplicate]

I'm using many basic commands of unix/linux. In Mac OS X Mavericks, I type cat for a file, but output was faulty. In example, content of the file named bar: foo bar Then: ...
-1
votes
3answers
4k views

cat /dev/null emptied my log file but size did not change

I'm quite new to Unix. Using Solaris 10 I faced the below issue. There is a large log file with size 9.5G. I tried to empty the file using the below command. # cat /dev/null file_log.txt By doing ...
4
votes
2answers
2k views

How to pipe a remote file to stdout over scp or sftp?

Using ssh, it is easy to print the contents of a file using ssh host 'cat file.txt' When ssh is disabled, and only SFTP is enabled, running the previous command gives the following error: ...
3
votes
1answer
83 views

Does cat never read from terminal?

Chapter 43. Redirecting Input and Output of Unix Power Tools, Third Edition has to say this about cat command: Standard input (stdin) normally comes from your keyboard. Many programs ignore ...
4
votes
2answers
158 views

(cp is to cat AS mv is to ?) mv multiple files into one file instead of cat * rm *

For everything in this question pretend the system only has one disk and filesystem. (we are not writing to different partitions, disks or filesystems) I am working on a project that cats very large ...