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

learn more… | top users | synonyms

2
votes
1answer
35 views

How to use “cat” command on “find” command's output?

I want to redirect the output of the find command to cat command so I can print the data of the given file. So for example if the output of find is /aFile/readme then the cat should be interpreted ...
0
votes
1answer
31 views

Can't terminate / suspend a background job

I am a beginner so I wanted to do a test for the Job Control Commands. So, I ran a cat command and then made it a background job using the bgcommand after stopping it with Ctrl +Z. Now I wanted ...
-2
votes
1answer
52 views

cat command appears to be adding extra $ character at the end of each line

I am trying to create a file and it looks like the vi editor is adding a $ at the end of each line. I don't know what's causing this or how to prevent vi from doing it. vi file.txt 12345 abcde cat -...
3
votes
0answers
33 views

slow file transfer through serial port with cat

I'm transferring a binary file to an embedded device using a custom AT command set. I'm running Lubuntu Linux on a virtual machine (Windows 7 host) and the virtual linux guest controls the physical ...
0
votes
1answer
27 views

Error while replacing date in a file using tr command

I want to replace date in a file with my date. For this, I am giving below command - tr '2016-05-25' '2016-06-17' < APCSE060.20160525 > TESTFILE alternatively cat APCSE060.20160525 | tr '...
1
vote
2answers
46 views

Specifying comma-separated command line parameters based on text file lines

I want to run a command like: command argument --parameter=param1,param2,param3 where param1, param2, param3 may be any number of parameters coming from a file params.txt, each on one line. I can ...
-1
votes
1answer
38 views

Why is `sudo cat /tmp/1 > file` wrong? [duplicate]

I do sudo cat /tmp/1 > /etc/udev/rules.d/69-libmtp.rules but I get bash: /etc/udev/rules.d/69-libmtp.rules: Permission denied System: Ubuntu 16.04 Linux kernel: 4.6
1
vote
0answers
24 views

Read a log file to extract various fields and count the occurance [closed]

I have a logger file like this: 2016-06-11 07:34:01.542 98459 [Thread-23-Job-parser-bolt] INFO JobLoader c.t.commerce.common.utils.APIUtils - Enrichment data updated successful for partnumber : ...
1
vote
4answers
769 views

With the Linux “cat” command, how do I show only certain lines by number

If I use cat -n text.txt to automatically number the lines, how do I then use the command to show only certain numbered lines.
0
votes
1answer
14 views

Create a file with the concatenated information of all files that start with “file_excel”, in chronological order

my system: Linux 2.6.18-406.el5 #1 SMP Fri May 1 10:37:57 EDT 2015 x86_64 x86_64 x86_64 GNU/Linux my shell: /bin/ksh My issue: I want to create a file: data_excel with the information of the ...
0
votes
2answers
36 views

Add time from all log files using bash

I want to extract time from all of my .log files and add all of these times into a single entity. My log files are placed in nested directories. Directory structure for my log files: |-- temp-system ...
3
votes
2answers
106 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
76 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 ...
2
votes
2answers
60 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
46 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
109 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
728 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
45 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
78 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
88 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
49 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
111 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: ÀýÓëöûcÎ=ÉÐÎTaüÍ8]ö¹mg:=Rú*@...
0
votes
1answer
32 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
66 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
72 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
68 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
249 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
47 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
41 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
23 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 date"@en/&...
3
votes
4answers
97 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
87 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: <script>addRow("...
59
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
404 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
77 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
60 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
80 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
52 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
261 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
66 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, /dev/...
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
194 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
95 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
379 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
152 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);
3
votes
2answers
154 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
173 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 ...