Questions tagged [cat]

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

Filter by
Sorted by
Tagged with
5
votes
6answers
332 views

Output file location and contents based on list of files

I have a file that contains locations of different files called locationfile.txt it contains: /home/user/documents/file1 /home/user/file2 /home/user/file3 Each text files have about 10 lines and I ...
17
votes
7answers
18k views

Is there a way to show only uncommented lines in a text file/script? [duplicate]

Many a times when manually grepping through a file, there are so many comments that your eyes glaze over and you start to wish there was a way in which you just could show it to display only those ...
1
vote
1answer
6k views

Uncompress and unarchive the .tar.gz file using cat, tar and gzip on one command line [closed]

How can I uncompress and unarchive a .tar.gz file using cat, tar and gzip on one command line? Is this even possible?
1
vote
1answer
2k views

echo for Print output

I want to use the echo command to show this output: 10 item in File but seems that the below command does not work: echo "$('cat file.txt | wc -l ') items in File"
1
vote
0answers
734 views

Get contents of a .gz file over SSH and pipe it to zcat and mysql

I have a recent.sql.gz file on a remote server. What I try to accomplish is the following: I want to open the file, push the content over SSH to my local machine, use zcat to uncompress the content ...
2
votes
2answers
477 views

How to remove ^M and proceeding lines from a text file?

I have following lines with ^M (return carriage). I want to remove ^M+proceeding line. You can notice there is a new line after each ^M, which is not desired. I purpose is to remove control character ...
21
votes
2answers
1k views

less file1 file2 | cat — why does it work?

When I uss less file1 file2 I get both files shown in the "less buffer viewer", but less file1 file2 | cat prints the content of both files appended to stdout. How does less know if it should show the ...
1
vote
3answers
90 views

How to cat a file with “or” options

I have a file name like /etc/auto.abc on server 1 /etc/auto.def on server 2 /etc/auto.ghi on server 1 I am writing a single script for all servers and in that I want to cat the file. Example: cat /...
0
votes
1answer
23 views

How to skip printing (say) the 2nd line of a file?

I have a .csv file where the first two rows contain header information. The second row is in an unfriendly format (punctuation, spaces, etc.), so I'd like to skip printing the second row and pipe the ...
1
vote
2answers
911 views

Why running `cat /etc/localtime` on PuTTY puts a stream of “PuTTY” in the prompt?

I was randomly experimenting and I found that running cat /etc/localtime on PuTTY and on xterm have different effects. Example: root@webtest:~# cat /etc/localtime TZif2 ▒ ▒▒Kmp▒▒ǀ▒▒▒p▒...
3
votes
2answers
3k views

How to monitor a serial connection @ 250000 baud?

I wish to directly monitor the serial-over-usb connection to my 3d printer, which runs at 250000 baud. e.g I might monitor it with cat /dev/ttyUSB0 However first I need to set the baud rate, e.g ...
22
votes
2answers
2k views

cat gives different error when opening non-existing file

Both of the following commands try to open a non-existing file foo, but the error messages are a little different. What could be the reason? $ cat foo cat: cannot open foo $ cat < foo -bash: foo: ...
0
votes
1answer
126 views

Dynamically extract comments from files using cat

I have a bunch of bash files, and each have a function and a comment block that describes that function. Example: ~/helpers/plugins/test-util.bash # Function Name: test_util # # Description: ..... ...
0
votes
1answer
47 views

How do I append contents from fileA.txt to fileB.txt? [closed]

I am trying to take updated contents from fileA.txt to update fileB.txt's information. I have already tried appending contents from fileA.txt to fileB.txt using the command, "cat /root/important/...
0
votes
1answer
85 views

cat multiple file in script truncates data when scheduled in cron

I'm cat'ing multiple files in a bash script on OEL 6. for f in /share/scripts/stats/*.stat; do (cat "${f}"; echo) >> /share/scripts/stats/finalmail.html; done When the script is triggered ...
0
votes
1answer
836 views

Piping cat to sendmail not respecting new lines

I have a script which runs a few sanity checks, outputs the results to a file which is then concatenated and piped to a sendmail function as so: { echo "$headers"; echo; cat health_check.log; } | ...
4
votes
2answers
534 views

“diff orig new” vs. “diff new orig” [closed]

When comparing 2 files using diff, the original file is provided as first argument, and the new (modified) as second argument. diff original new Presumably, the logic behind this ordering was to ...
3
votes
1answer
8k views

cat: write error: Invalid argument

Writing to a custom character device using cat 123 > /dev/chardev gives cat: write error: Invalid argument I have changed the permissions to 666 and even tried it with sudo. Still the same ...
0
votes
1answer
54 views

Combined linux commands not writing outfile.txt

I want to search in a log file (real-time) for the contents of msg="yxyxyx" and then write the unique values to outfile.txt I wrote this: tail -f /var/log/firewall.log | sed -n '/msg=/{s/.*msg=//;s/\...
1
vote
1answer
198 views

How to convert interrogation mark character in accented letters

I have a file containing accented letters with cat, I get interrogation marks voltm�tre with less, I get accented letters with brackets voltm<E8>tre with vim, I get the accented letter ...
2
votes
2answers
61 views

How to loop a line of values using ',' and the print it as a list

I'm trying to loop a file using a delimiter with a ',' and the print out those values in a "list" but I'm not sure how to get all the values of delimiter. I have a file with emails like this (all in ...
3
votes
1answer
576 views

How to avoid broken pipe in commands with cat?

Why does this simple command fails using emacs shell (eshell)? cat file.txt | wc I have a file with 10241 lines. Each line has less than 50 characters. Around 90% of the times I launch this command,...
0
votes
2answers
347 views

How do I use the cat command to show the contents of a text file with numbered paragraphs? [duplicate]

I want to print a text file in terminal with numbered paragraphs using the cat command.
2
votes
2answers
79 views

Will `cat ~/foo* > ~/results/output.txt` preserve the ordering of `~/foo*`?

I have hundreds of files of the form ~/foo.x.y. The files are ~/foo.0001.0010 ~/foo.0011.0020 ~/foo.0021.0030 ... ~/foo.4371.4378 I want to combine all of these files into a big file ~/results/...
0
votes
1answer
140 views

Cat filename not working

I've redirected topas output to a file in AIX 6.1, but the file is not readable using cat: $ cat a.txt $ While using pg it shows perfect output: Topas Monitor for host: jsitrs0058 Interval: ...
1
vote
2answers
60 views

I want to create a file named “Grocery List” (2 words in the name of this file)

I do know that we can use cat > fire to make a file with the name "fire". But if the name of the file contains 2 words like "Grocery list", how does one make that? Since cat > Grocery list ...
0
votes
2answers
200 views

When I cat a pid file I get a %,why and what that means? [duplicate]

I googled, but it ignore the "%". all about pid. My system is macOS. Here's the code: cat /usr/local/var/run/php-fpm.pid #I got this. 7260% #When I use vim open it. only have text "7260" 7260 ...
0
votes
3answers
6k views

Modifying cat command to number paragraphs and display last paragraph only

I have a text file for which I need to do three things: Modify the "cat" command to highlight keywords whilst showing the complete contents of the file. SOLUTION FOUND Modify the "cat" command to ...
11
votes
2answers
2k views

cat redirection

Say a file called abc exists in the current directory and it has some text in it. When you execute the command: cat abc > abc Why do the contents of the the file abc disappear? Why does the ...
3
votes
1answer
87 views

Create directories from lines of a file [duplicate]

I'm cating a file, and the output is something like this: Help me my friend Temptation Sorrow True Love Vanilla Sky I was here SOS ... I'm trying to create directory of all of these lines. What I ...
6
votes
4answers
4k views

cat special characters meaning

with cat, I use the -A flag and I can't find what these characters mean anywhere. For example: cat /proc/cpuinfo > output cat -A output One of the lines is this: processor^I: 7$ I know the $ ...
1
vote
1answer
61 views

Combining files in a directory by header and omitting shared content

so I have found a question on here that is the opposite of what I would like to do here: Concatenate multiple files with same header. I am trying to merge or concatenate 2 files,within a directory ...
0
votes
1answer
154 views

concatenate .doc files with cat

I'm trying to concatenate several .doc files none of them bigger than 15 KB, I'm trying the usual cat file1.doc file2.doc file3.doc > new_file.doc But despite the result is an almost 200 KB new ....
1
vote
1answer
1k views

Adding column to a table by concatenating values from other columns

I have several csv table as follow: YEAR;MONTH;DAY;RES1;RES2 1971;1;1;1206.1;627 1971;1;2;1303.4;654.3 1971;1;3;1248.9;662 1971;1;4;1188.8;666.8 From this I would like to create a new column that ...
1
vote
2answers
154 views

formatting the output of a UNIX file

I have a file that contains the following information: uid: jdoe mail: jdoe@yahoo.com How do I make the output to look like the following uid: jdoe mail: jdoe@yahoo.com I appreciate any ...
1
vote
2answers
604 views

bash script that incorporates content from a file as part of a command

I'm trying to put together what I guess could be called a bash script (not that my bash-scripting abilities are anything to brag about). What I'm trying to do is feed a line from a text file--a text ...
0
votes
3answers
608 views

echo lines of file - but no more than N characters per line [duplicate]

I would like to print the tail of a file (could be also head or cat in general) to the screen but restrict the number of characters per line. So if a file contains ... abcdefg abcd abcde abcdefgh .....
0
votes
1answer
6k views

apt - Command line option 'i' [from -info] is not understood in combination with the other options

I was making a shell script with that installs packages from a list. The code looks like this: apps="$(cat ./foo/bar/packages.txt)" apt install $apps But, I get the error E: Command line option '...
1
vote
0answers
650 views

dd and cat both reporting no space left on device

I have a windows 8.1 Pro laptop with a 500GB HD and a 500GB portable USB HD. I boot up my laptop with a linux live CD so that I can use dd or cat. Testing cat: cat /dev/sda > /dev/sdc cat: write ...
5
votes
3answers
291 views

Why does cating an executable keep changing the title of PuTTY?

Its usually been seen that if an executable is cated, provided that its a huge file, it keeps on changing the title of the 'PuTTYapplication until its done printing the binary to the STDOUT with those ...
-1
votes
1answer
592 views

How to cat file from output of other command?

If I do: perldoc -l WWW::Mechanize I get the following output: /usr/local/lib/perl5/site_perl/5.16.3/WWW/Mechanize.pm How can I, in one line, print to the screen the contents of the file given by ...
2
votes
2answers
681 views

Sum of columns for rows containing a specific term

I'm wondering if there is any sed or awk command that can sum all columns for the rows with an identical identifier. For example, my file data.txt is set out as below, except that it contains ~1800 ...
4
votes
3answers
532 views

Difference in cat sth vs cat < sth [duplicate]

I realized that cat sth and cat < sth both happen to give same output. Are they the same?
3
votes
3answers
948 views

Accessing each line in .txt file, download and rename links

Let's say I have a .txt file where I have a list of image links that I want to download. example: image.jpg image2.jpg image3.jpg I use: cat images.txt | xargs wget and it works just fine What I ...
11
votes
4answers
30k 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 ...
1
vote
1answer
399 views

Can't terminate / suspend a background job

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 to first terminate ...
-2
votes
1answer
940 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 -...
4
votes
0answers
735 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
274 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
2k 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 ...