Questions tagged [cat]
cat is a standard Unix utility used for concatenating files or printing specific file on the standard output.
677
questions
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 ...
2
votes
1
answer
130
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
1
answer
28
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
-...
0
votes
5
answers
109
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 ...
0
votes
1
answer
47
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
...
0
votes
1
answer
48
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?
0
votes
1
answer
98
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 ...
2
votes
1
answer
34
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
2
answers
159
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
...
0
votes
1
answer
43
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
1
answer
155
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&...
0
votes
4
answers
155
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....
0
votes
2
answers
113
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 '...
1
vote
1
answer
84
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,...
-5
votes
2
answers
167
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?
1
vote
0
answers
109
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-...
8
votes
2
answers
4k
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 ...
0
votes
3
answers
65
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" ...
3
votes
2
answers
1k
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
│ ├─...
0
votes
3
answers
107
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 ...
1
vote
4
answers
120
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 ...
0
votes
2
answers
86
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 ../...
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 ...
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 ...
0
votes
1
answer
529
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 ...
9
votes
2
answers
805
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?
0
votes
1
answer
92
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 ...
3
votes
4
answers
536
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
1
answer
334
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 /...
0
votes
0
answers
170
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/...
0
votes
1
answer
415
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.
...
6
votes
2
answers
11k
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 ...
4
votes
1
answer
884
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 &...
2
votes
3
answers
769
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 ...
30
votes
2
answers
3k
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.
...
1
vote
3
answers
408
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.
...
0
votes
1
answer
630
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 ...
0
votes
0
answers
452
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 ...
1
vote
0
answers
275
views
Why does cat command only read from stdin?
I'm trying to figure out why my cat command refuses to acknowledge the file I provide.
I know that cat ignores filenames when they are absent or a - is provided, but I am not doing either of those ...
0
votes
1
answer
589
views
How can `cat` read a file without a file descriptor?
I'm learning Linux procfs, which utilizes a virtual file system where operations like open, read, write, and release are processed by functions registered to it.
I've left the open and release to null ...
1
vote
1
answer
308
views
Sum of Column with Rows Specific and write that value to .txt file
I have number of text files which has 70000 rows and 2 column. I would like to sum entries of 2nd column from 40000 to 70000 row and value of sum is to written to new text file.
e.g:-Suppose
Data1_old....
7
votes
3
answers
2k
views
What are the benefits of this command line (/usr/bin/awk '{$1=$1};1') instead of pure cat
I am reading the AWS eic_harvest_hostkeys script and I don't understand this line:
key=$(/usr/bin/awk '{$1=$1};1' < "${file}")
What is the of benefit awk?
Isn't key=$(/bin/cat "${...
0
votes
1
answer
722
views
Running script in parallel using xargs and cat
I'm inserting a lot of CSV files into database. I want to do it in parallel, for example run 4 processes. Right now I do it with the script like this:
find . -name "*.csv" | xargs -n 1 -P 4 ....
0
votes
2
answers
742
views
How can I use nmap -p and cat 'file'?
I am trying to create a simple bash script that can run the "specific" port scan on mulitple IPs and Ports using nmap -p.
The issue I am having is that when it reads the port# followed by ...
-1
votes
2
answers
625
views
Bash: Append rows from multiple files to one output file and add file name as column
This is a continuation of my previous question
Bash: Choose row with the highest value in specified column in multiple files and create one output file with rows containing the max
The solution I used ...
-1
votes
3
answers
88
views
Changing the place operator in a csv file
I've been editing a CSV file so I can import it into postgres. At this point I want to change the operator from column 5 to the left side of the column when the value is negative"-". When it ...
0
votes
0
answers
85
views
Keep every process in 1 execution block in CSV handling
I asked some questions about how to handle a csv file and this result was numerous processes.
Every month I get several TXT files in a Google Drive directory. I need to process, unite and load this ...
0
votes
1
answer
495
views
Concat files with similar name in multiple subdirectories to new file
I am trying to concat all files with similar names but in different subdirectories.
I found this solution for exact file matches but I am not sure how to adapt it for partial matches
Create new ...
3
votes
1
answer
805
views
Linux find command to get all text in the file and print file path
I need get all the texts in the matching file in the folder , however at the same time need to get the matching file path as well . Can you please advise , how can I get the matching file path as well ...
0
votes
0
answers
1k
views
How to pipe an input into the cat command
I was reading an answer regarding sending large files from one Linux system to another by quick methods, and I was trying this solution
The answer is saying that if you don't want to use the tar ...