Questions tagged [cat]
`cat` is a command-line utility used to concatenate or copy the contents to standard output from a file or standard input (if no file name is passed).
119
questions
49
votes
9
answers
47k
views
Can `cat` show files using code markup in colors?
Sometimes I quickly want to view the contents of a file from the command line. For this I of course use cat, but it is often source files in Python, Java or simple HTML. For these files it would be ...
47
votes
1
answer
52k
views
omit filenames in grep
I am greping a string from multiple files, but the one undesired side effect, is the filename prefacing the output. How can I suppress the filename outputs using only grep?
$ grep -i lp lpNet*
...
30
votes
5
answers
15k
views
What is the difference between "cat < filename" and "cat filename"?
The simplest way to display file contents is using the cat command:
cat file.txt
I can get the same result using input redirection:
cat < file.txt
Then, what is the difference between them?
23
votes
2
answers
40k
views
How to use `cat` to see the top of a very long file?
I'd like to know how to
cat my-verylong-file
and show it from the top instead of the end. Like the man command does.
23
votes
2
answers
5k
views
What's wrong with my cat command? [closed]
I lent a friend a computer with Ubuntu 12.04 LTS on it, and he messed up the cat command.
$ cat testfile.txt
cat: meow!
$
Can someone tell me how to fix this? please?
Output of which cat:
/bin/cat
20
votes
4
answers
99k
views
What is 'cat' used for?
I've seen the cat command come up in some online stuff and I was curious as to what cat did and what it's for in the context of someone who is just doing some simple command line stuff.
18
votes
2
answers
1k
views
When run cat says: "Hello, nothing to see here! Move along!"
PLEASE NOTE: To view the comments on this and the extended discussion on this, which includes all that has been tried, please look at this chat room.
Today when I ran the cat command, instead of the ...
17
votes
5
answers
46k
views
Appending a line to a file in the cat command?
I can do cat file.txt to get the contents of a file but I also want to tack on a final line of my own choosing.
I tried piping (cat file.txt ; echo "My final line") | but only the final line is ...
14
votes
1
answer
41k
views
How do I 'cat' a text file but start from the bottom instead of top
I have a very big text log file of about 37MB.
Using cat file | more I can view the file contents one page at a time.
The problem is that this always starts from the top - the old entries.
How can ...
10
votes
3
answers
7k
views
cat command doesn't show the lines of the text [duplicate]
i am trying to read an odt file from terminal. When i type cat myfile.odt it shows me an image like this
9
votes
3
answers
27k
views
Difference between cat and sudo cat? [duplicate]
Can you tell me what the difference is between cat and sudo cat?
All I know so far is that cat is used for displaying contents of file and concatenation.
8
votes
4
answers
6k
views
How to replace cat with bat system-wide Ubuntu 22.04
I am using Ubuntu 22.04 with bash, pretty vanilla, and have added alias cat="batcat" to ~/.bashrc. The program batcat or bat being referred to can be found here: https://github.com/sharkdp/...
6
votes
2
answers
15k
views
What is the correct output of cat /etc/apt/sources.list?
I have Ubuntu 12.04 LTS. I need the correct output because I edited it because it wasn't working but it has only made it worse.
6
votes
1
answer
9k
views
How to unzip only the first few lines of a zip archive?
I have a zipped text file a.zip I want to read the first 10 lines of it. Is it possible to do that without unzipping the whole file?
6
votes
2
answers
4k
views
I just ran cat /dev/zero and now cat is hanging
I ran cat /dev/zero and it now just hangs whenever I run a cat command. I pressed Ctrl+C to stop that command.
Have I broken something, and how can I fix it?
5
votes
5
answers
6k
views
Numbering paragraphs with the 'cat' command
I'm currently trying to find a way to use the cat command to show a text file as automatically numbered paragraphs for a project I'm doing, but I haven't been able to find a single command.
Example:
...
5
votes
3
answers
9k
views
What is the output of `cat image.png`?
What does the output mean when you do cat image.png?
Is this what the image actually is made of?
Does it matter what file extension the image has?
5
votes
1
answer
79k
views
How to use the cat command to find a specific word in a textfile [closed]
I did some research but I was unable to find anything to help, I need to find the word "war" in a text file, I know that I can use the cat command, but I need to modify it somehow, can someone help?
5
votes
2
answers
4k
views
One command for ls and cat functionality?
Okay guys, this is an experimental question warning!
I often confuse cat and ls when quickly working on the console. Not because I forget their meanings, no. Just because I type without deeply ...
5
votes
1
answer
2k
views
`wc -c` gives un expected results?
I have a .log file which is a binary file(BSC0000.log). So Viewed it in a HEX viewer(OKteta) and exported it directly in to a string(split_space.txt). With spaces in the middle as
00 DF 00 45.
The ...
5
votes
2
answers
10k
views
Cat to named pipe causes hang
I'm attempting some streaming with FFMpeg, and I think I have finally found the solution I need to screen blanking. This requires writing PNG's to a named pipe and then having FFMpeg read them as an ...
4
votes
2
answers
2k
views
How to create an alias for a "cat" file usable in a path
I have two huge files (150G each) and I need to use a tool for which I should supply them as a single file (since the tool only accepts one file). However, I do not want to merge these files for ...
4
votes
1
answer
31k
views
cat: write error: Broken pipe
I'm running a command:
cat urls.txt | xargs -L 1 -P 5 timeout 40 wget
This downloads all the URLs in urls.txt
This used to work fine, but recently I changed the URLs I am downloading from something ...
4
votes
2
answers
424
views
cat | dd inconsistent behavior
From a given a file, I have a requirement to create a copy that is padded with zeros to a specific size.
If you create a file with the following.
echo test >testfile
The output of the following ...
4
votes
2
answers
1k
views
Printing over ssh: "cat file | lpr" or "lpr file"
I am looking at how to print a file over ssh. Two websites (The Linux Documentation Project and Computer Hope) suggest the command "lpr" but both seem to suggest two different methods, with no obvious ...
3
votes
4
answers
3k
views
Is there a way to read characters backwards from the end of a file in the terminal?
For instance, less allows you to read line by line, starting from the beginning. Is there a similar utility or line that could be run in the terminal that could display a file backward character by ...
3
votes
7
answers
3k
views
How to display line numbers with pygmentize
I often use the command pygmentize filename.py to show color source files with code formatting. This works like a charm. I now also want to show line numbers like cat -n filename.py does.
I read ...
3
votes
1
answer
193
views
Bash with cat for automatic merging pair of files
I have a list of files starting with L- and a folder called L with inside files with the same name, for instance L-some and L/L-some.
For each file L- I want to merge append its content into L/L-. I ...
3
votes
1
answer
3k
views
How do I edit a file in /proc that can be viewed with cat, but is not editable by mousepad and abiword?
As the question says, I need to edit my /proc/acpi/wakeup file, but when I open it with any text editor, it shows blank file. cat command, on the other hand, displays correct file contents in terminal....
3
votes
1
answer
363
views
How to “cat” or “less” a libreoffice impress .odp file?
Is there any way to cat or less a .odp file just like we have for .odt files as mentioned
here
3
votes
1
answer
4k
views
How to bulk extract bitrate data from videos and output them in a text file?
I have several videos in a folder;
~/Downloads/movie1.mkv
~/Downloads/movie2.mkv
~/Downloads/movie3.mkv
I would like to extract the bitrate for each file, and output the data into a single text file,...
3
votes
3
answers
601
views
cat and Pipe to Run Command Won't Take Two Arguments
I have been using this command:
cat urls.txt | xargs -n 1 -P 10 wget -q
to download text files of URLs. This worked fine when my URL file was like:
http://domain1.com/page.html
http://domain2.com/...
3
votes
4
answers
61k
views
How does one read the contents of a text file located on the desktop using the terminal? [closed]
My goal is to open and the read the contents of a file that is located on my desktop using only the terminal to do so. My file has a space (" ") in its name, this has become troublesome because, cat ...
3
votes
2
answers
328
views
If I cat file to other file is there way to get them separate again?
If I use cat pic1.png >> pic2.png is there way to get the pic1.png out of that pic2.png?
I know it works if I simply use some archive file and just simply unarchive it but I want to know is it ...
3
votes
1
answer
561
views
Program for Ubuntu to detect cat-like typing?
A feline hacker has invaded my home. She frequently crawls across and sits on the keyboard, causing all sorts of mayhem. I have gotten into the habit of locking my computer when I step away for a ...
2
votes
4
answers
1k
views
how can I List files in order
I had an 18GB file I needed to download on a less than great Internet connection. Torrenting wasn't an option. So I busted up the file into 100 segments, and eventually, all of it downloaded. Now I ...
2
votes
3
answers
2k
views
How to redirect the output of 'cat' into a different folder?
I have a Python script, EulerianCycle.py, and an input file, euleriancycle.txt.
I am able to get the correct results by doing py EulerianCycle euleriancycle.txt > cat euleriancycleout.txt into the ...
2
votes
3
answers
6k
views
Giving cat output to rm
I have file names in a file which I need to delete in a different directory.
Let's say I have x and y files in dir a. How do I delete it using cat?
I tried,
rm -f a/{`cat a.txt`}
a.txt has ...
2
votes
1
answer
46k
views
Can the cat command edit a text file as well as read it? [duplicate]
I am trying to learn all I can about the cat command. I am going to be using it for its light weight performance and its ability to work in nothing but a command line.
I know it can create a text ...
2
votes
1
answer
596
views
Why does the more command not work when bound to a keyboard shortcut?
I have two commands that both work in terminal:
notify-send "$(more /home/tim/autest.sh | head -1)"
and
notify-send "$(cat /home/tim/autest.sh | head -1)"
putting them in a script like this:
#! /...
2
votes
3
answers
3k
views
Bash, command to variable (cat), output is on 1 line, <pre> is not working
Issue
In bash, output is on 1 line from command, so <pre> is not working in html tag.
log=`cat ../local/log/$(ls -t ../local/log | head -1 )`
echo '
<tr style="background-color: rgb(250,...
2
votes
2
answers
10k
views
GZip of drive image created by using `dd` command
I created yesterday a drive image using GZip.
I opened the 51.3 GiB file named ssd.img.gz to see one icon thats a package of 3.9 GiB, yes, thats THree point Nine Gigabytes in size and has the name of ...
1
vote
1
answer
1k
views
What is the right way to exit the interactive CLI of the command "rev"?
Please check the code below and notice the difference between exiting the cat command and rev command
heer@heer-pc:~$ cat
mark
mark
^C
heer@heer-pc:~$ rev
mark
kram
^Cheer@heer-pc:~$
1
vote
3
answers
717
views
Parameters of the 'cat' command [closed]
cat -b test1.txt
This command is meant to skip blank lines and number the rest.
cat -n test1.txt
This command numbers lines no matter what.
I tried both of them. One on a file with only spaces ...
1
vote
2
answers
7k
views
How do I search in multiple files with "cat"? [duplicate]
What I want is to find within a directory all the files containing a match and when it finds the match it shows the file where that match was found.
example
cat * | grep password:
Here it will show ...
1
vote
1
answer
6k
views
How do I write a script to output an html file?
What am I doing wrong in this script?
#!/bin/bash
cat > /tmp/flash-viewer.htm <<- _EOF_
<HTML><HEAD><TITLE>Flash Viewer</TITLE></HEAD><BODY>
<object ...
1
vote
2
answers
154
views
How to take value as value without considering it as string when we do cat and grep
I have created the utility that need to be run in all the system without any error by creating the required environment. When ever I run the following command it will take the path value from a config ...
1
vote
2
answers
2k
views
How to pipe a text file containing mongod arguments to mongod command
So usually I start a mongod process with 2 arguments like this
~$ mongod --dbpath /media/0CB6-189A/linux/mongodb/data --logpath /media/0CB6-189A/linux/mongodb.
But I don't want to specify the ...
1
vote
1
answer
1k
views
DD vs cat for forensic works (carving in USB)
I'm using the foremost,photorec and other tools for recovering data.
What is the best way for cloning the USD or HDD for recovery files?
Which one should I use dd or cat or ddrescue?
If you ...
1
vote
2
answers
7k
views
cat vs grep vs awk command get the file content which one is more efficient and less time consuming?
Lets say I have file content like this:
this is a simple file for testing purpose
with few lines in it.
to check the cat and grep command to verfy which is best and less excution time consuming
...