cat is a Unix utility used for concatenating files.

learn more… | top users | synonyms

3
votes
1answer
136 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
0answers
48 views

Sometimes command with many pipes makes empty output [on hold]

I am wondering what causes this problem and finding the solution (except for temporary file). When I execute certain code CHIMP+testis_uniq_expression.out file with like this, it makes empty output. ...
0
votes
1answer
50 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
234 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
54 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
32 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
65 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
36 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
39 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
208 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, ...
4
votes
6answers
529 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
217 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
21 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
1answer
55 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
228 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
389 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
56 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
125 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 ...
2
votes
2answers
57 views

Backed up over wrong hard drive

I've just written over the wrong hard drive using the command: sudo sh -c 'pv /dev/sdb >/dev/sdc' How do I go about undoing this? I was creating the first even backup of the drive, and I backed ...
0
votes
2answers
32 views

concatenate .out files

Can I combined multiple .out files with the cat command in bash or csh? Additionally I want only the header of first file to be concatenated and I was thinking of using the tail function for that. ...
3
votes
1answer
58 views

How to set default tabs only for cat?

I prefer to set tabs 4 however this may have some side effects, such as for example ls out put may look not properly aligned. How might I configure the terminal / cat to use four spaces for tabs for ...
3
votes
2answers
194 views

How to interleave the lines of two or more files?

I have tried to get the 2 files output in a single file. I have tried below command: cat file1 file2 but here file2 data is appending to file1. What I need is file1 1st line followed by file2 ...
14
votes
2answers
1k views

How do I “cat and follow” a file?

A file is being sequentially downloaded by wget. If I start unpacking it with cat myfile.tar.bz2 | tar -xj, it may unpack correctly or fail with "Unexpected EOF", depending on what is faster. How to ...
2
votes
2answers
536 views

continuous reading from named pipe (cat or tail -f)

I have configured rsyslog to log certain log events to /dev/xconsole: *.*;cron.!=info;mail.!=info |/dev/xconsole /dev/xconsole is a named pipe (fifo). If I want to see what is being logged, I ...
0
votes
2answers
349 views

Passing a variable to a bash script that uses 'EOF' and considers the variable a literal [closed]

in this script i end up with "$1" being saved to the /test file. #!/bin/bash cat > /test << 'EOF' $1 EOF the truth is.. i need to keep 'EOF' as 'EOF' because my argument($1) contains ...
2
votes
2answers
141 views

“cat” command: how to automatically escape everything that might be a violation?

If you copy the contents of httpd.conf and then paste it into a cat command.. such as this one.. #!/bin/bash cat > /test << EOF pasted here.. EOF you run into this error: -bash: ...
4
votes
6answers
2k views

How to tell “cat” command to not hang on when there is no path provided?

I am simply trying to get a bash script to return the content of a text file. #!/bin/bash cat $1 the problem is.. when the path to a file is not fed to this bash script... how will it even close ...
-2
votes
3answers
219 views

Replace $ with £ using cat Command

I have file test_output_archive.svd with some Dollar signs ($). I have generated a shell script Replace_dollar_pound.sh with cat command to replace dollar symbol with Pound (£) script is working on ...
0
votes
3answers
83 views

How to fork a “cat” command?

This is my bash script. #!/bin/bash oo="`cat /etc/httpd/conf/httpd.conf`"; cat > /a.txt << EOF $oo EOF it simply reads /etc/httpd/conf/httpd.conf and writes it to /a.txt, the problem has ...
15
votes
5answers
585 views

Is it possible to make zcat output text even if it's uncompressed? [duplicate]

The problem is I have some database dumps which are either compressed or in plain text. There is no difference in file extension etc. Using zcat on uncompressed files produces an error instead of the ...
10
votes
5answers
1k views

Difference between cat and '>' to zero out a file

Are these two commands any different on how they go about zero-ing out files? Is the latter a shorter way of doing the former? What is happening behind the scenes? Both $ cat /dev/null > ...
1
vote
1answer
142 views

Difference between cat * and cat * >>

To merge multiple files in a dir I have tried: cat * myfile.log but this seems to just merge line and line and is thus very slow So using instead: cat * >> bigfile merges the files much ...
0
votes
1answer
70 views

removing the last line of a file not working? [duplicate]

I have this TXT file that is created by a bash script and at the end I want to remove the last line of that file that is an empty one. head --lines=-1 r3.txt > r4.txt sed '$d' r3.txt > r4.txt ...
0
votes
0answers
120 views

cat echoes to serial port

Connecting my Windows PC to a Linux system (Wheezy) via the serial port (RS232) basically works except one problem when sending a message from the the PC terminal the Linux system. The reception of ...
4
votes
1answer
262 views

How can I get less or cat to use color in the output from .cat of my .bashrc, similar to vi 'ing it?

When I vi my .bashrc file it is colorized, i.e. but when I cat or less the file I get all white, i.e. How can I get cat (and less) to have color? cat does have color for my ruby .rb files but ...
4
votes
2answers
144 views

Spliting `File` and `directory name with space' via shell script

I've got a file called Files.txt having following content: TestApp/Resources/Supporting Files/main.m TestApp/Resources/Supporting Files/AppDelegate.h TestApp/Resources/Supporting Files/AppDelegate.m ...
8
votes
4answers
2k views

Why does “cat ttyUSB0” not produce output?

I connected an infrared receiver to a USB port ... (the last line of dmesg tells device file) $ dmesg [10496.596063] usb 7-2: new full-speed USB device number 2 using uhci_hcd [10496.751112] usb 7-2: ...
2
votes
2answers
1k views

Why using cat on binary files messed up the terminal and how?

If I understand correctly the cat manual: concatenate files and print on the standard output cat will take files as argument and print them on standard output. What I don't get is if I use the ...
10
votes
2answers
4k views

Fastest way to concatenate files

I've got 10k+ files totaling over 20GB that I need to concatenate into one file. Is there a faster way than cat input_file* >> out ? The preferred way would be a bash command, Python is ...
2
votes
1answer
78 views

< and << in UNIX /Linux

What is the option <<and < are used in linux for??? For example cat << abc.txt I know its a stupid question, but i was not able to search it on google as i did not know what ...
1
vote
1answer
146 views

Cat and Less give different output

I executed the following command # top > /home/user/top_output.txt Nothing Happened for a while and then i pressed Ctrl+C. When i checked the file that was created, it had the contents in it. So ...
4
votes
2answers
906 views

How can I get the tac command on OS X?

I like to use tac to reverse the output of cat. However, it's not available in the Mavericks terminal. I tried to find it on MacPorts and again it's not available. Can anyone please show me how to get ...
0
votes
2answers
785 views

How can I concatenate all files in a directory together in one command line operation? [duplicate]

I have 1000 csv files in a directory. I would like to concatenate them all together in order. They are named img_size_1.csv to approx img_size_1000.csv This answer is close but assumes a list file. ...
9
votes
4answers
3k views

Grep from the end of a file to the beginning

I have a file with about 30.000.000 lines (Radius Accounting) and I need to find the last match of a given pattern. The command: tac accounting.log | grep $pattern gives what I need, but it's too ...
2
votes
1answer
693 views

cat file to udp, pt 2: send 1 udp packet per ^C-delimited line

Yesterday I asked a question about catting a file over a UDP socket in bash. The solution we came up was netcat -c -w 1 -v -u -s 127.0.0.1 239.255.0.1 30001 < test.txt. This worked in the sense ...
2
votes
1answer
273 views

cat file to multicast

I have a text file (test.txt) which represents captured network data. The actual protocol is text-based, with NULL line endings, so this isn't a problem. I need to run this test captured data ...
0
votes
1answer
139 views

Passing multiple scripts to shell over ssh

I have a somewhat lengthy script which sources other scripts to include the functions there. I'd like to execute this script remotely via ssh. Now I thought to make one script file of it (without ...
2
votes
3answers
1k views

Can't cat a file or make a directory: contradictory output?

I am getting output from a terminal in Ubuntu 12 that I don't understand. $cat sublime no such file or directory $mkdir sublime cannot create directory 'sublime': File exists How can both of these ...
8
votes
1answer
1k views

How to store an image file in bash variable?

After I use the following command, pngString="$(cat example.png)" echo -n "$pngString" > tmp.png I can't open the tmp.png as a PNG file. Maybe some information is lost when I use $pngString ...