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

learn more… | top users | synonyms

1
vote
1answer
36 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: ...
48
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
392 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
53 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
30 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
31 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 ...
3
votes
1answer
43 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
164 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
22 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
20 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, ...
31
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
72 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
52 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 ...
2
votes
3answers
342 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
59 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
45 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
101 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
54 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
27 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
32 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
102 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
100 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
29 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
33 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
43 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
39 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
177 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
83 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 ...
6
votes
1answer
123 views

Function to simplify grep with an often used log

First off, sorry if this is a painfully newbish question! I'm trying make a function that simplifies grepping a log I have to work with on a regular basis. I'd like to use extended regexp with it ...
3
votes
1answer
33 views

Storing result of cat as different index values

i have parsed a file using catand now I want to save the result of it in array. var1=$(cat abc.txt | grep .........) and the var1 looks like 33 23 51 11 16 43 5 50 4 2 12 29 32 28 47 41 7 20 38 ...
0
votes
0answers
28 views

Why does `cat` stand for? [duplicate]

I've always been told it is concatenate, but every time that I see cat used they are just dumping a file to the terminal. What are they supposed to be concatenating?
1
vote
1answer
41 views

Sending a list (text file) of files and pathnames to xargs

I have a file that contains the paths of various files. files.txt : /path/to/file1.txt /path/to/file2.txt ... /path/to/fileN.txt I want to use it in a script to process the files. cat files.txt | ...
8
votes
6answers
400 views

Force newlines with cat wildcard printing

I want to use cat with wildcards in bash in order to print multiple small files (every file is one sentence) to standard output. However, the separate file contents are not separated by a newline, ...
0
votes
3answers
191 views

Problems with the Cat command [closed]

I'm looking to number my paragraphs within a text file, I'm pretty sure I have to use the command cat -n or cat -b but I'm not sure how to use it, could someone expand upon this please.
3
votes
2answers
78 views

Using find -exec how to print name of file in front of each line?

Similar to, but beyond: find . -iname "somepatter*txt" -print -exec cat {} \; How might the file name from each file be printed in front of each line with the results from find?
1
vote
1answer
34 views

What happens when I echo with `-e` argument?

As you can see, I have created index.php as follows: $ echo -e "<?php passthru(\$_POST[1])?>\r<?php echo 'A PHP Test ';" > index.php and then: $ cat index.php <?php echo 'A PHP Test ...
14
votes
6answers
2k views

Why there is such a difference in execution time of echo and cat?

Answering this question caused me to ask another question: I thought the following scripts do the same thing and the second one should be much faster, because the first one uses cat that needs to open ...
4
votes
3answers
131 views

How to append data to buffer in shell script?

I'd like to do following using shell script: (for simplicity, I use same data for INPUT. In real case, the data changes with loop label jj) #!/bin/sh for jj in `seq 100`; do cat INPUT.file ...
0
votes
3answers
68 views

Make curl/cat not scroll down when given long text?

I have made a program where I read the text from a url using curl. The problem is that when given texts that are larger than the terminal window, it automatically scrolls down to the bottom, I want to ...
0
votes
3answers
64 views

combining n number of files with cat command

I have n number of files, I have stored filenames in a list and I want to combine them. I am doing this manually, i.e. If n=3 cat ${filename[1]} ${filename[2]} ${filename[3]} > newfile If the ...
26
votes
5answers
2k views

Why pipe to cat only to redirect? [duplicate]

I occasionally see things like: cat file | wc | cat > file2 Why do this? When will the results (or performance) differ (favourably) from simply: cat file | wc > file2
5
votes
2answers
438 views

Is it better to use cat, dd, pv or another procedure to copy a CD/DVD?

Background I'm copying some data CDs/DVDs to ISO files to use them later without the need of them in the drive. I'm looking on the Net for procedures and I found a lot: Use of cat to copy a ...
0
votes
1answer
362 views

piping a password located in a file to the ssh command [duplicate]

So I need to login as a lot of different users to a server using ssh and I'm tired of copying the password from the files, which contain the passwords for the users, each time. I can't change it to ...
0
votes
4answers
442 views

Single line command to cat last file in ls -lrt output? [duplicate]

System log files are serialized and I use ls -lrt to show me the most recent file. I then cat that file. This requires typing a long serial number each time. How can I cat the last file appearing in ...
0
votes
4answers
93 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
39 views

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

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
126 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
94 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
230 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 ...