cat is a standard Unix utility used for concatenating files or printing specific file on the standard output.

learn more… | top users | synonyms

3
votes
2answers
102 views

Question about concatenation instructions

I have a semicolon-delimited csv file and a Korn shell script that do some elaboration. I'm searching to understand what these two instructions do in Korn shell: num_rec=`cat test.csv |wc -l|tr -d " ...
2
votes
1answer
42 views

How could I EOF `cat` through `netcat` without closing connection?

I have run into a problem where I have a ncat server with the command ncat -l [port] -k -c "cat > foo; cat > bar". When I connect to this server through netcat, it allows me to write to the file ...
1
vote
2answers
49 views

Safe execution of cat command without executing arbitrary code

I do this little file based on a combination of hexadecimal, that can broke cat and the terminal showing the file with cat, reset does not worked anymore, it is maybe putting cat in a kind of loop? ...
0
votes
1answer
28 views

How can I prepend a header to a file when using cat?

If I have a file called test.php and its contents are $a = "apple"; echo PHP_EOL; echo " the value of \$a is $a" . PHP_EOL; I want to cat the contents of test.php to STDOUT but I want to add a ...
2
votes
2answers
33 views

Ouput to a file and read it [duplicate]

I am trying to output the ps command to a file in /home/username/ps.txt. I want to create the file on the go, write the output of ps to it and also read the same in a single command. I tried this: ...
3
votes
3answers
106 views

Reverse sequence of a file with POSIX tools?

Is there any clean, clear-cut POSIX equivalent to tac? Readability as well as succinctness should both be considered.
13
votes
4answers
666 views

dd: multiple input files

I need to concatenate chunks from two files: if I needed concatenate whole files, I could simply do cat file1 file2 > output But I need to skip first 1MB from the first file, and I only want ...
0
votes
0answers
36 views

cat tty freezes the system while I can observe tty through screen

So I have been subject to this weird behaviour. A few days ago I could read my GPS data on Beaglebone Black (latest Debian) on ttyO4 using cat /dev/ttyO4 But since yesterday whenever I try this ...
2
votes
2answers
67 views

Does the cat command pass back a file or the contents of the file?

Compare the following commands: cat f.txt | grep "someText" grep "someText" f.txt They both seem to work. But the documentation for cat says cat outputs the contents of the file rather than the ...
0
votes
3answers
78 views

I want to copy a remote txt file via SSH, but without using root access

I want to copy my hosts to remote /etc/hosts but it doesn't work. I know root SSH access makes things easier, but IMHO root SSH access is a little dangerous. cat /etc/hosts|ssh samba2 "sudo su -c ...
1
vote
1answer
44 views

Creating a virtual file whose contents are determined programmatically [duplicate]

Is it possible to create a virtual file in unix, whose contents are determined programmatically when the file is accessed, a bit like the files in /proc? For example, I have a program that retrieves ...
1
vote
3answers
104 views

Why 'cat' can't read content of pdf files?

When tried the command cat < 1.pdf it printed a very large output, which was totally incomprehensible to me. The content of 1.pdf was abc. The output was like this: ...
0
votes
1answer
28 views

Cat won't access file in openSuse Tumbleweed ('Invalid argument' error)

I have just installed the latest version of openSuse Tumbleweed and was going through the file system familiarising myself with it when I found a file in /dev/lightnvm called 'control'. I attempted to ...
1
vote
2answers
62 views

Why does Linux not allow `cat`ing a directory? [duplicate]

I read in The Design of the UNIX Operating System that directories are files containing the names of each file they contain. So I tried cating one on my Mac, and it resulted in an error: cat: ./: Is a ...
1
vote
4answers
66 views

cat results of grep

I am trying to concatenate the results of my grep search. my grep search finds about 4 files on my system and outputs them in a new line for each file. I thought by passing this information to tr '\n' ...
-4
votes
1answer
63 views

What does “|” between arguments in cat command do?

I understand what the "cat" command does. I.e. cat file1 file2 > file3 Will put the contents of file1 and file2 in file3. (If I am not mistaken) But what exactly does: cat file1 | file2 > ...
3
votes
3answers
182 views

/bin/cat: Argument list too long

I have 119766 files in a folder. They are CSV files. I want to find out total number of lines of all files. I'm trying to run following command: cat * |wc -l But the following error occurrs: ...
3
votes
1answer
42 views

How to upload a file and then check it and run some other commands using only ssh, cat, and diff in a single SSH session?

The goal is to change some parameters on a lot of devices on connections that are kind of unreliable (wireless)--according to csv that has the format: IP,Parameter,Parameter I would like to make a ...
1
vote
2answers
37 views

how to store output of echo and cut to a variable

I have a file named test which has two columns one having ID and other having status. I want to loop through the file and print IDs where status have one particular value (e.g. 'ACTIVE'). I tried ...
1
vote
2answers
22 views

How can I paginate a UTF-8 file and see the right characters?

If I use cat on a file containing UTF-8, it displays properly: % cat /tmp/sample <concept code="endangeredLanguage"> <description value="The language is endangered at the given ...
3
votes
4answers
80 views

Provide default value if command returns with non-zero exit code

I have some configuration in file config and would like to cat that file. However, sometimes config doesn't exist. In this case, I would like to have my command output a default value. Perhaps ...
1
vote
1answer
73 views

cut column range sed/awk/cat

I'd like to cut a certain range of text (i.e. characters 17-63) repeatedly from a *.txt file, which is several thousand lines long. One line looks like this: ...
58
votes
4answers
5k views

Difference between “cat” and “cat <”

I was working through a tutorial and saw use of both cat myfile.txt and cat < myfile.txt. Is there a difference between these two sequences of commands? It seems both print the contents of a file ...
6
votes
2answers
403 views

Why do here-documents attempt shell substitution even on a commented line?

I wanted to see how some ASCII art looked in terminal so: $ cat <<EOF ...
1
vote
3answers
64 views

Can I redirect the output of a program to cat with a pipe?

I have a folder with three files and basic contents: $ tail * ==> file1 <== file 1 contents ==> file2 <== file 2 contents ==> file3 <== file 3 contents I would like to see the ...
1
vote
2answers
50 views

Cat all files in a folder including filename by using a for loop?

With this for loop which I execute directly in the shell, I am able to cat the contents of all files in a folder, with the value beside of it: $ for f in *; do echo -e "\t"$f"\n"; cat $f; done ...
2
votes
1answer
67 views

cat [file..] pipe another cat command

cat ~/.ssh/id_rsa.pub | ssh user@123.45.56.78 "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys" can someone explain how the quotations works. From what I understand. I am reading ...
2
votes
1answer
49 views

Sanity check (MD5 sums) fails after joining a file

I'm having a problem passing a sanity check, when combining a split file back to its original state even if it tarred with atime-preserve. Example below. filename=FILENAME newfilename=FILENAME2 ...
1
vote
2answers
199 views

Why does the following shell sequence ends so quickly?

Let be the files com and fic whith the access rights defined in the following shell sequence: $ cat com if tty>/dev/null then read x else read x<fic fi echo $x $ cat fic abcd $ ls -l ...
3
votes
5answers
221 views

Concatenate contents from stdout and from file

How can we concatenate results from stdout (or stderr) and a file into a final file. For example ls -a | grep text1 concatenate with file2.txt into a final result (not file2.txt), without storing ...
0
votes
1answer
58 views

how to send data from serial port to printer?

I have a telephone system that is connected to my old Ubuntu machine and is receiving SMDR data from it. Connected to dev/lp0 is a dot matrix printer, phone system connected to /dev/ttyS0 Currently I ...
0
votes
0answers
21 views

What is in /dev/pts and why does /dev/pts/0 react strangely to cat? [duplicate]

What exactly is in the /dev/pts folder? And why does cat /dev/pts/0 give you the option to type, and copies what you typed back to standard output again upon the press of enter? If I am correct, ...
32
votes
7answers
3k views

Is it a UUOC (useless use of cat) to redirect one file to another?

If I want to make the contents of file2 match the contents of file1, I could obviously just run cp file1 file2. However, if I want to preserve everything about file2 except the contents—owner, ...
1
vote
1answer
182 views

dd, cat & openssl: block size & buffer size

Here it says that when using dd through dm-crypt to overwrite a block device, only the default dd block size should be used because dm-crypt's block size is the same (512 bytes), and increasing dd's ...
1
vote
1answer
81 views

Concat all remotely distributed files in your cluster

I want to concatenate all abc_2015-12-15.txt files present on my cluster.Is there any best way to achieve this ? One way is to use below command across all nodes till all files concatenated :- ssh ...
1
vote
3answers
374 views

Copy content from files X and Y to create file XY but XY content is all lowercase

What's the right command to copy the content from file X and File Y to create a new File XY with all letters being lowercase?
0
votes
2answers
143 views

copy file with cat in execl() finction

how can I copy a file with full path and rename it in C program using execl? can I use this instruction: execl("/bin/cat","cat",path_source,">",path_destination,NULL);
2
votes
2answers
115 views

Cat files except one [duplicate]

I'm looking for something to concatenate all files with given extension within a directory, except one. Like: cat *.txt !(DISCARD.txt) > catKEPT This should concatenate all *.txt files in ...
4
votes
1answer
153 views

How does cat 'know' the optimum block size to use?

From reading this, it seems that when copying data to a different hard drive, cat automatically uses the optimum block size (or very near it). I wonder how it determines the optimum block size, and ...
3
votes
1answer
77 views

Need Explanation For Multiple Arguments And Input Redirection With Cat

Files along with their contents:- ~$cat a aaa aaa aaa ~$cat b bbb bbb bbb ~$cat c ccc ccc ccc Commands that I need explanation:- ~$cat 0< a aaa aaa aaa ~$cat 0< a b bbb bbb bbb ~$cat 0< a ...
0
votes
1answer
29 views

data from text file in a form of text

I have multiple directories (different names) which contain text files of he same name. I have to extract lines (numerical values) from those text files and create a single text file with a list of ...
1
vote
2answers
34 views

Concatenate selected extensions to output

How to automatically concatenate selected extensions to output with same filename but different extension? Input files (simplified): File1.txt File1.csv File1.tsv File2.txt File2.csv File2.gff ...
2
votes
2answers
232 views

File merging - same name, different extension

How would you merge different input .txt and .tsv files (within a directory) who have the same name but a different extension into an output file? Input: file1.txt, file2.txt, file1.tsv, file2.tsv ...
2
votes
3answers
227 views

curl page source from text file containing URLs

I have a text file containing up to 100 URLs. I am able to curl the page source from them using: cat /path/to/url.txt|xargs curl -o /path/to/output.txt This will download the page source for all of ...
2
votes
1answer
34 views

need help with awk merging rows by sequence from multiple files into one file

have alot of files and need to merge strings between themself by groups of three files. each file ~100-500 rows and result file ~100-200mb seems like awk or sed can help me with paste or without it or ...
2
votes
2answers
46 views

How do I write the output of Portage to a txt file?

I would like to be able to write the output of Portage commands, along with other commands, that I perform in tty (that is, the screen-wide terminals started with Ctrl+Alt+Fn where n represents an ...
1
vote
1answer
45 views

Matching content in two files and creating a new file [closed]

I have a script to read each line of a file called saitem.unl and store 3 variables in LINENO, ORDREF and PROD. I then use these fields to read prod.unl and if matched set GROUP to field $3. I want to ...
2
votes
2answers
54 views

Find files with particular filename format, cat each one with a header file, and save result to original file for each such file [duplicate]

I have a bunch of html files and I want to cat them all (individually) with a header file (several lines at least in length), say header.txt. I'm almost there. I can cat each file with the header file ...
2
votes
5answers
211 views

How do I cat a file I got from stdin without xargs

In an effort to learn the shell better, and without always having to resort to xargs, I have been trying to discover any other ways to do: find . -name *.tcl | xargs -I{} cat {} xargs make it feel ...
1
vote
1answer
163 views

How to merge multiple files based on a timestamp

I have 2 files File 1: 01:12:00,001 Some text 01:14:00,003 Some text 02:12:01,394 Some text File 2: 01:12:00,001 Some text 01:12:01,029 Some text 01:13:21,123 Some text I need output as ...