Questions tagged [cat]
cat is a standard Unix utility used for concatenating files or printing specific file on the standard output.
693 questions
0
votes
2
answers
134
views
How to prevent side effects when using an alias (e.g. cat aliased to batcat)?
I want to alias cat to batcat. Yet I do not want to break any script on my system that may depend on cat.
How to ensure that it won't break existing scripts?
I am on an Ubuntu machine on a bash ...
0
votes
1
answer
86
views
How can I use a here-document on the left-hand side of a pipeline? [duplicate]
Show lines passed by here-document in the stdout:
cat <<EOF
foo
bar
baz
EOF
foo
bar
baz
I want to match some string with grep via pipe:
cat <<EOF
foo
bar
baz
EOF
|grep 'ba'
Why can't ...
0
votes
1
answer
203
views
How does "Useless cat. ... or 'cmd file | ..' instead." should be applied?
I have the following line:
isUbuntu=$(cat /etc/os-release | grep '^ID=ubuntu$' | wc -l)
It works fine
Now, through VSC and mostly with the ShellCheck extension is indicated two warnings messages as ...
0
votes
1
answer
55
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 ...
0
votes
1
answer
417
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 ...
0
votes
1
answer
144
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 ...
2
votes
2
answers
383
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 + ...
0
votes
2
answers
161
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
...
0
votes
1
answer
478
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 ...
2
votes
1
answer
181
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 ...
0
votes
5
answers
608
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 ...
-1
votes
2
answers
1k
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?
2
votes
1
answer
69
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
...
0
votes
1
answer
104
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.
...
0
votes
4
answers
316
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....
1
vote
1
answer
238
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,...
1
vote
0
answers
184
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-...
0
votes
3
answers
106
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" ...
0
votes
3
answers
826
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 ...
0
votes
2
answers
112
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 ../...
2
votes
2
answers
3k
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 ...
9
votes
2
answers
1k
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?
3
votes
4
answers
744
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
....
0
votes
0
answers
303
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/...
7
votes
2
answers
24k
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 ...