Skip to main content

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
0 votes
1 answer
25 views

view a bunch of text files in the terminal [duplicate]

I've got a bunch of text files and pdfs in a directory. If I enter evince *.pdf ..all the pdfs open up in separate windows, I do this quite often. When I enter cat *.txt ..was pleasantly surprised ...
cardamom's user avatar
  • 592
0 votes
2 answers
52 views

Cat file and heredoc to pipe

I do some automatic checks and want to send a mail if a file has changed. I want the mail body to contain the new version of the file, some static text and the old version of the file, so what I do is ...
MortenSickel's user avatar
  • 1,373
0 votes
1 answer
52 views

Redirect command output to file (append) and then append a newline character

I'm running the following one-liner: cat input.txt | xargs -I{} bash -c './script.sh "{}"' >> output.txt The script works and does exactly what I want it to do. The only issue is that ...
dlyk1988's user avatar
  • 103
0 votes
0 answers
26 views

dd or cat for disk images [duplicate]

I used to read and write images with dd (normaly bs=1m) as it has been writen so many times but lately I more often than not simply used cat not really noticing any difference. When not using any of ...
wiebel's user avatar
  • 23
1 vote
1 answer
73 views

How to specify a number of copies in print lpr command using ssh

When I want to print a document using ssh from my local machine I use cat path/to/document.pdf | ssh [email protected] lpr This will print my document.pdf that is located in my local machine using a ...
zebda's user avatar
  • 13
0 votes
1 answer
51 views

Standard input stream redirection

stdin: Generally standard input, referred to as stdin, comes from the keyboard. When you type stuff, you're typing it on stdin (a standard input terminal). A standard input device, which is usually ...
Guilherme Woolley's user avatar
1 vote
1 answer
44 views

Why does /usr/bin/time coupled with GNU parallel output results before command's output rather than after command's output?

Scenario: $ cat libs.txt lib.a lib1.a $ cat t1a.sh f1() { local lib=$1 stdbuf -o0 printf "job for $lib started\n" sleep 2 stdbuf -o0 printf "job for $...
pmor's user avatar
  • 619
2 votes
2 answers
256 views

Bash frequently fails to redirect stdout to a file (from cat)

I commonly append to text files using cat: cat >> FILE I use an alias to avoid accidentally overwriting the file (with a single >): alias a='cat >>' Enter changes the line and Ctrl + ...
user598527's user avatar
0 votes
0 answers
88 views

output of cat when file contains asterisks and quotes [duplicate]

I have a command stored in a text file command which looks like this: command_name par1 par2 path/with/backslashes -option_1 3 -option_2 0.05 --option_3=* -p 'P001=A' -p 'P002=B' ... The three dots ...
Michele Ancis's user avatar
0 votes
2 answers
85 views

checking to see if an arg is a file and printing accordingly

I have the following code that takes in a file via an arg and if none exists, take it from stdin: file= column= pattern= path= cmd="echo" while getopts "f:c:e:" opt; do ...
Mathew's user avatar
  • 243
1 vote
0 answers
43 views

Why can't I cat a file, pipe it to jq, and redirect the output to another file? [duplicate]

I want to use jq to pretty-print a JSON-format file, and pipe the result to another json file. My first instinct was cat foo.json | jq > bar.json but this results in an empty bar.json: $ cat <&...
StoneThrow's user avatar
  • 1,787
0 votes
1 answer
249 views

"man cat" mentions "LFD." What is "LFD?"

man cat says: -v, --show-nonprinting use ^ and M- notation, except for LFD and TAB I checked info cat, and it uses the same acronym: ‘-v’ ‘--show-nonprinting’ Display ...
Daniel Kaplan's user avatar
7 votes
1 answer
2k views

When redirecting top to a file, why does cat command on that file display output of multiple top attempts?

I am customizing a Linux system with a kernel of 6.4.0, and I have noticed a strange issue. When I execute top > a.txt and then open a window to execute cat a.txt, I find that the cat a.txt result ...
just a student's user avatar
2 votes
1 answer
148 views

Getting a short string from a long one without spaces

I have a file with a huge string without spaces in it (something like: "A":123,"B":456,"C":789...) I want to get X amount of chars before and after a specific value (like ...
Ran's user avatar
  • 125
0 votes
1 answer
112 views

Which portion of boot.log files are binary?

My system keeps seemingly randomly failing to boot after a kernel update. So I am reading logs to try to determine the cause of the issue. Here is one of the boot logs: $ sudo cat /var/log/boot.log.1 -...
li816's user avatar
  • 1
0 votes
5 answers
353 views

In bash how to copy an URL within a displayed text file without using the mouse?

Let me take you to this short trip: Open terminal. Type cat <any text file in your current working directory, containing a URL, at the beginning> | head The first 10 lines of that text file are ...
futurewave's user avatar
0 votes
1 answer
367 views

Line length limit for cat reading from keyboard [duplicate]

I have a single line of about 30000 characters (and no newline) in my clipboard. I want to put that into a file. I tried the following command in a GNOME terminal (Ubuntu 20.04): cat > file.ext ...
k314159's user avatar
  • 447
-1 votes
2 answers
375 views

/proc/uptime command gives weird result

When i use "cat /proc/uptime" i get result 10257.21 31389.01 what does this mean that my computer is slow? how to read about this more can you recommend me anything?
cahjcu2's user avatar
1 vote
1 answer
600 views

What is the max size limit for using split and cat combination?

I have backed up a file in zip format on Ubuntu whose size is 6.5GB. Trying to transfer it to a USB stick so needed to split since I got error “file size too large” while copying. (Ideally I want my ...
Gautam's user avatar
  • 121
2 votes
1 answer
39 views

How to concatenate files and give another name to output based on the match from another file?

I have a directory data in which there are several fastqs like below: SRR13456784_1.fastq SRR13456784_2.fastq SRR13456784_3.fastq SRR13456785_1.fastq SRR13456785_2.fastq SRR13456785_3.fastq ...
stack_learner's user avatar
0 votes
2 answers
460 views

Merge files with same name in multiple subfolders

I have multiple folders with a lot of files, Each folder has txt files of the same name, I want to merge files with the same name into one txt file. Example: folder/ -sub1 -sub2 -sub3 ...
Roq's user avatar
  • 15
0 votes
1 answer
70 views

Why are commands reading from /dev/stdin get a status "[1]+ Stopped" when sent to background?

I have tried running the following commands: cat base64 /dev/stdin md5sum /dev/stdin tail /dev/stdin In all cases when I do: ^Z $ bg $ jobs I get the status: [1]+ Stopped instead of [1]+ Running. ...
Marinos An's user avatar
0 votes
1 answer
465 views

How to use a path to a directory with a space within variable to cat all files within the directory?

I have a variable with path to folder1 containing a white space: TEST=path/with\ space/to/folder1/ I want to concatenate all files within a folder1 with cat but it gives an error: cat "$TEST&...
trilisser's user avatar
  • 103
0 votes
4 answers
212 views

Concatenating txt files and keeping directory name

I am concatenating thousands of .txt files together but I want to keep the path written above the text of each .txt file so I can refer back to the directory to review files if needed. Example: file1....
linuxuser24569's user avatar
0 votes
2 answers
181 views

Redirecting the content of two files [duplicate]

I want to redirect the content of two files to a single file named ooo.txt. I also want to only take some specific lines of the second file using grep (in this case 5 lines before and 25 lines after '...
Mnako8's user avatar
  • 15
1 vote
1 answer
133 views

How can I concat results in the here document?

I have this script: while read $item; do # Some bash logic here done <<< "$({ cat /path/to/some/file; echo; })" Now I want to also use find to find the name of some directories,...
Saeed Neamati's user avatar
-5 votes
2 answers
1k views

Getting the windows version of a "cat" command? [closed]

I would like to have this script's windows version cat name-of-APK.apk | openssl dgst -binary -sha256 | openssl base64 | tr '+/' '-_' | tr -d '=' How can I get that?
Adam Varhegyi's user avatar
1 vote
0 answers
135 views

how to seperate column data and store in array in bash script, where the column seperator is <space> and number of space is different in each row?

Let l have a file that contain a data like this: -ab-a--a-- 1 abcd abcd 934M Nov 2 00:14 abc_de-123.456.xyz-2022-11-02_1234567890.zip -ab-a--a-- 1 abcd abcd 45M Nov 2 01:39 abc_de-...
Bhawishya Khanal's user avatar
8 votes
2 answers
8k views

Terminal, won't execute any command, instead whatever I type just repeats

I need to open a file named -. (I am playing this hacker game) And when I try to use command cat -- - , after I type that, any command I type does not work, for that fact, everything I type just ...
kakashi7593's user avatar
0 votes
3 answers
79 views

script using linux command to search word

I have the file, In the file data few lines have only one word, if such a case is present i want to print following line as the present line can I get some tips for this grep -E "module" ...
Santhosh Nayak D.'s user avatar
3 votes
2 answers
2k views

How can I write in multiple files at once using 'cat'?

This question is kind of related to my previous question. This is the output of tree: [xyz@localhost Semester1]$ tree . ├── Eng │   ├── credits │   ├── links │   └── notes ├── IT │   ├── credits │   ├─...
Random Person's user avatar
0 votes
3 answers
448 views

How can I create an expanding buffer?

I want to be able to scroll back through all of the output for each session in terminal. When using cat on large files, for example, there could be hundreds, or even thousands, of lines (I write a lot ...
Lee's user avatar
  • 97
1 vote
4 answers
149 views

Sed delete everything before and after characters

I'm running on android this Command: dumpsys activity activities | grep mFocusedApp Output: mFocusedApp=ActivityRecord{273535b u0 com.any.some/.app.AnyActivity t5595} Expected: com.any.some I need ...
Name F's user avatar
  • 5
0 votes
2 answers
93 views

Meaning of those two expressions with cat?

This is first time that I am using Linux, and I need to understand some concepts about two commands. I would be happy if you could explain the process one by one. What does this command do? cat ../...
Daffy's user avatar
  • 1
0 votes
0 answers
14 views

How to escape standard input when "cat f - g" [duplicate]

man cat shows the following example: cat f - g Output f's contents, then standard input, then g's contents. How do you escape the standard input and proceed to output the 2nd ...
MattP's user avatar
  • 111
2 votes
2 answers
2k views

read line by line and execute cat with grep

Im building a script to load from a file content and then use to cat and grep in another file. The problem is that is not showing any values while executing the grep. If i do the command manually it ...
macieira's user avatar
  • 121
0 votes
1 answer
1k views

can 'cat' command be a pipe target?

I used to do bash programming long, long time ago but over a period of time I moved onto other programming languages. My work demands I look into a bash script and I found this piece of code which I ...
stirfries's user avatar
  • 103
9 votes
2 answers
956 views

Split two concatenated files

I have Afile made by the equivalent of cat a.gif b.7z > Afile. How may I split Afile into the original a.gif and b.7z files?
user536180's user avatar
0 votes
1 answer
173 views

Why does cat randomFile.txt mess up with my terminal? [duplicate]

I am simply generating a pseudo-random content file with. dd if=/dev/urandom bs=1M count=1 of=./filetone.txt To then cat it cat ./fileone.txt The issue is that upon completing with this command it ...
freddie_ventura's user avatar
3 votes
4 answers
674 views

How to concatenate the first 100 files in a directory?

I had 4000 text files with unique filenames in a directory. Is there any Linux command to concatenate only the 1-100 files. cat 1.txt ... 100.txt > 1.100.txt cat 101.txt ... 200.txt > 2.200.txt ....
sunnykevin's user avatar
0 votes
1 answer
614 views

How to `sudo cat` the contents of a symlink

I have created a symlink foo to the file /bar/baz using $ ln -s /bar/baz foo $ ls foo Here /bar/baz is a log file that only root has read permissions for. Now I would like to print the contents of /...
Max's user avatar
  • 173
0 votes
0 answers
237 views

Not able to mount disk partitions simultaniously after cloning by cat/dd command

In my Ubuntu 20.04.4 LTS virtual machine(in azure), I had 2 data disks (/dev/sdc & /dev/sdd) connected. I attached 2 disks to VM as per: https://docs.microsoft.com/en-us/azure/virtual-machines/...
KIRAN KUMAR B's user avatar
0 votes
1 answer
681 views

Shell scripting: Receiving error `cat: illegal option -- A` when passing `CA` as parameter to shell function, other 2 letter params work as expected

I thought this was a weird one-off glitch at first, but now I've found a second completely different bash function with the same behavior, so I'm reaching out for help because it's driving me mad. ...
badcrocodile's user avatar
6 votes
2 answers
17k views

What is the difference between `cat EOF` and `cat EOT` and when should I use it?

I'm used to use cat > /path/to/file << EOF when I, in a bash script, printed more than one line into a file... I was checking old code of my company and I found the cat EOT instruction ...
k.Cyborg's user avatar
  • 507
4 votes
1 answer
1k views

feed output of command to another command as file

I can make config file of tor with cat <<EOF command as follows : cat <<EOF SocksPort 9050 ControlPort 9150 DataDirectory /usr/var/lib/tor/torrc EOF but it can save output with redirect &...
XaNaNtX's user avatar
  • 43
2 votes
3 answers
1k views

concatenate all the text files in all the sub folders into one giant text file

Ok so the situation is that I have an unknown number of sub-directories that all follow the same naming profile folder0, folder1, folder2, folder3 etc Now each folder will have 3 text files and these ...
jessyjack's user avatar
31 votes
2 answers
4k views

When using cat to create file, I have to type ctrl+d twice to finish the input, is this expected? [duplicate]

I just learned a trick to create a new file with the cat command. By my testing, if the last line is not followed by a newline, I have to type ctrl+d twice to finish the input, as demonstrated below. ...
Fajela Tajkiya's user avatar
1 vote
3 answers
543 views

How to concatenate files in reverse order

I am looking to concatenate a list of files in a directory in the reverse order that they appear in the list. This is different from tac as tac will concatenate the files with reversed line order. ...
sarahParker's user avatar
0 votes
1 answer
963 views

What are the weird characters from an image file?

So i am pretty new to linux and i am learning basic commands. I am also very interested to know how things work under the hood, so sometime after i learned both the cat and nano commands, i tried ...
Konstei's user avatar
  • 13
0 votes
0 answers
626 views

"> $logfile" does not truncate, file size goes to 0 and a second later, is back to full size [duplicate]

I have a script that writes to a logfile like this: $ nohup myscript.sh > myscript.out 2>&1 & when the log file gets very large, I need to truncate it like this: > myscript.out I ...
chiwal's user avatar
  • 1

1
2 3 4 5
14