cat is a Unix utility used for concatenating files.

learn more… | top users | synonyms

0
votes
4answers
54 views

piping commands not working as expected I need explanation

I am trying to do the below touch ~/scratches/scr6.txt | cat ~/scr.txt > ~/scratches/scr6.txt | cat /dev/null > ~/scr.txt I don't know why scr6.txt is always empty, however doing the below ...
0
votes
1answer
26 views

How to concatenate tables from different directories with only one header [on hold]

I have several directories ("amazon", "niger",...), in which I have several subdirectories ("gfdl", "hadgem",...), in which I also have several sub-directories ("rcp8p5", "rcp4p5",...). In this last ...
3
votes
4answers
96 views

Concatenate table without header

I would like to concatenate several tables and just keeping the header in the first line (and thus not having a new header each time that a new table has been concatenate). Does anyone know how to do ...
0
votes
2answers
24 views

Bash output command too large, can't read it!

I'm having some troubles on Ubuntu 14.04 initialization, it fails to mount an SSH folder and gives me the option of a manual recovery by pressing M, displaying a command-line logged at root user for ...
0
votes
1answer
84 views

Properties of cat command

a simple question, can I create a file at a location I want & using cat command & without using pipes & and the location is some other place than I where I am currently. (I would ...
0
votes
0answers
47 views

How to convert a merged file generated by cat command into individual files in terminal?

I have already merged several files into one file using cat command in linux. Now, I need the individual files; please let me know how I can recover individual files from merged file? Thanks a lot
2
votes
3answers
59 views

reverse cat files order

I need to do log analysis and I am facing problem that cat access.log* display latest log file first. I tried to sort logs which takes a lot of time because I have logs from couple of years back. And ...
3
votes
4answers
73 views

Not able to cat a string from a file under a string of another file

I have encountered a strange issue in concatenating the files using catcommand. I have two files with one string in each of them: file1: ABC file2: DEF Either I do cat file1 file2 or I do ...
0
votes
2answers
51 views

Display filenames with grep

I'm looking for a way to display the filename when using this command: cat *.tcp | grep "tcp" | grep "open" | sort | uniq Is there a way to do it?
5
votes
2answers
301 views

Why does `cat` seem to iterate over JSON arrays?

I'm puzzled by this behaviour of cat when trying to output a heredoc containing JSON in bash 3.2: input: $ cat <(cat <<EOF > {"x":[{"a":1,"b":2}]} > EOF) output: {"x":["a":1]} ...
1
vote
0answers
30 views

overlayfs root filesystem, cannot read /etc/mtab

I'm doing the following: mkdir /tmp/upper /tmp/work mount -t overlay overlay -o lowerdir=/,upperdir=/tmp/upper,workdir=/tmp/work / ls -l /etc/mtab > lrwxrwxrwx 1 root root 19 27. Feb 09:16 ...
8
votes
1answer
88 views

OS X, bash: less works on open file descriptors, cat doesn't

In a bash script I'm working on (which has to run on Ubuntu and OS X), I need to redirect the output of hundreds of commands to a file. Rather than appending &>... to all of them, I simply do ...
1
vote
1answer
37 views

Adding a crontab - syntax

crontab -l | { cat; echo "0 0 * * * /path/to/cron/job"; } | crontab - I took this line from the net, to add a new cron job. It works well and good. I got the doubts, 1) Why do we need the curly ...
28
votes
6answers
3k views

Is 'cat' a shell built-in or an external program?

When I use the type command to find out if cat is a shell built-in or an external program I get the output below: -$ type cat cat is hashed (/bin/cat) -$ Does this mean that cat is an external ...
4
votes
2answers
157 views

Cat file1 into file2 after specific pattern match

I have file1 & file2, I want to cat file1 into file2 after match of 22 pattern. Can I do it with cat or I need to go for awk or sed file1 aa bb cc file2 11 22 33 44 Resultant file2 11 ...
1
vote
1answer
79 views

Merge multiple HTML files in reverse order?

I have multiple HTML files for this book. I am trying to add them in opposite order. I've tried: cat *.html >> merge.html I've tried to use tac on the list of downloaded files by time to no ...
0
votes
3answers
100 views

Concat 1000 files within a directory [closed]

I know we can concat files by cat file [file] [[file] ...] > joined-file. I have directory which contains lots of files. I want to concat all of them. I want to concat 1000 files irrespective of ...
6
votes
2answers
761 views

bash - why does \x0d\x20 erase the line

This is the view from gedit editor: and the view from vim editor: I then try to grep it, it did grep successfully if i put Log instead of Tog, but the output is corrupted: [xiaobai@xiaobai grep]$ ...
3
votes
2answers
69 views

When does cat finish reading from a pipe?

Given the following code, why does cat only print the contents of the pipe after I've typed \n or CTRL+D? What are the conditions for cat to actually print what it read? #include <stdio.h> ...
0
votes
4answers
173 views

What the equivalent of “grep | cut” using sed or awk?

Say I had a config file /etc/emails.conf email1 = user@dinkum.dorg email2 = user@winkum.worg email3 = user@stinkum.storg and I wanted to get email2 I could do a: grep email2 /etc/emails.conf | ...
0
votes
1answer
26 views

How to execute several lines into a .txt

I am using SSH; In a folder I have the next files: -rwxrwxr-x 1 german german 48 Apr 29 10:45 prueba.txt -rwxrwxr-x 1 german german 23 Apr 29 10:43 script1.sh -rwxrwxr-x 1 german german 23 Apr ...
0
votes
3answers
47 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
114 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
63 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
72 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
121 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
362 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
150 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
55 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
255 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
211 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
52 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
244 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
32 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
97 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
61 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
64 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
175 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
1k 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
225 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
77 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
404 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 ...
2
votes
3answers
145 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
144 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
2k 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]+ ...
101
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
456 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
68 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
213 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
499 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 > ...