Questions tagged [cat]
cat is a standard Unix utility used for concatenating files or printing specific file on the standard output.
649
questions
0
votes
1
answer
26
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.
...
4
votes
2
answers
1k
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
162
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 &...
1
vote
3
answers
66
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 ...
28
votes
2
answers
2k
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.
...
0
votes
3
answers
58
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
79
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
49
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
71
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
67
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
70
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
1k
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
129
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
136
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
128
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
75
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
62
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
99
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
114
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
165
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 ...
2
votes
2
answers
192
views
Cat alternatives for writing terminal input to file?
When I want to quickly write something to a file that either get's pasted or manually input from the terminal, a quick cat > something.txt and Ctrl+D to close, is a nice shortcut.
However of course ...
0
votes
1
answer
53
views
When storing text on a USB drive, how do I make cat not hang?
Warning: I used these commands on a drive that had nothing on it (/dev/sdb). Do not attempt this on a drive with anything important on it.
I was experimenting some, and I discovered that the ...
0
votes
1
answer
109
views
Why Command "cata/etc/..." does not give me any results? [closed]
Why if I type:
cat/etc/passwd
or
cat/etc/shadow
the termnal give back me the message:
no such file or directory found ?
At least I should visualize me like user
2
votes
0
answers
144
views
Why does `cat` followed by appending to a file seem to overwrite itself?
Consider the following two (sets of) commands:
$ cat *.d | wc -l
and
$ rm -f tmp
$ cat *.d >> tmp
$ cat tmp | wc -l
I would expect the two of these to output the same value. However, when I ...
0
votes
1
answer
45
views
Load/Connect automatically to the Linux server session using Mputty
Looking for a help on Loading the putty sessions through Mputty.
I can login to my app servers(Linux) only through Jumphost. After login to jumphost i need to perform the ssh to connect my App servers....
0
votes
2
answers
280
views
I don't understand `cat` behaviour when running `cat | ls`
I know this is a useless command but I would like to understand why, wether in bash or zsh, when I enter cat | ls, cat will prompt me for input but only but will return after just one line whereas for ...
0
votes
1
answer
53
views
Schrodinger's cat
When I run a cat command as a background process,
$ cat &
and then try to kill it,
$ killall -v cat
it says that it killed cat with signal 15, but also that cat was only stopped. Upon running $ ...
1
vote
3
answers
61
views
Merging files from most recent
I wish to get the command for merging files from the most recent to the oldest in bash from a particular directory. Meaning files with newer dates are saved before ones with older dates
1
vote
1
answer
56
views
Fusing files line by line in a directory according to their type
I have a function, save, that is been called by other functions in a for loop and the function in question is to fuse files of the same type in a particular directory (copy the contents of each of the ...
2
votes
3
answers
54
views
Return string of a line in a file with multiple line after a matching pattern
I have a file with multiple lines in it.
I am trying to get a string that appears after a specific pattern...
Here is the command i am trying to do:
sed -n -e 's/^.*DB_PASS=//p' <<< $(cat /...
4
votes
2
answers
807
views
How to visualize EOF in bash
/dev/null is a special Linux file which discards everything is written to itself and which provides EOF when read.
I would like to read /dev/null to obtain and visualize this EOF. If I try:
$ cat /dev/...
2
votes
1
answer
165
views
ddrescue generate mapfile on partial image after cat --generate-mode
Having a HDD of 1TB (931.5G). I did:
sudo sh -c 'cat /dev/sdf >disk_1t.img'
But it stopped with read error at 908G.
Thought next step, (should have been first), is to use gnu ddrescue. Problem is ...
-1
votes
5
answers
239
views
Concatenate several files in directory with a prepend and append file
I have a directory of files that need two files merged to each one.
For simplicity, let's use intro.txt and outro.txt.
So, for files file1.txt to file3.txt I would like new files that contain
intro....
0
votes
0
answers
54
views
Why I must type something after cat << to make it work? [duplicate]
I've seen questions about cat << EOF so it's not duplicate.
If I do:
piotr@thinkpad:~$ cat <<
bash: syntax error near unexpected token `newline'
I have error but when I do:
piotr@thinkpad:...
0
votes
0
answers
115
views
Can dd (or something like it) create an ISO encapsulating an Ubuntu virtual machine?
In a Lubuntu ISO booted in a VMware Player VM in lieu of that VM's Ubuntu installation, I can run this command to create an image of the Ubuntu installation:
sudo dd if=/dev/sda bs=16M conv=sync,...
0
votes
1
answer
60
views
cat ./* >> large.txt decreases in size
I'm a novice in bash scripting. I wrote a script that concatenates many files from different directories into large files
#!/bin/bash
for f in foo/$1/*; do
if [ -d "$f" ]; then
...
2
votes
1
answer
192
views
Playing, recording, and streaming sound with cat and /dev/dsp
A couple of comments on Hacker News suggest that, on FreeBSD, you can:
use cat to send a file ( a .wav file for instance ) to the audio
speaker (/dev/dsp).
record from the mic using a similar method.
...
0
votes
2
answers
117
views
what is difference between less and cat with respect to reading binary files?
While I'm trying to read the file /var/log/boot.log with less, I will get the this message:
[amirreza@localhost ~]$ sudo less /var/log/boot.log
"/var/log/boot.log" may be a binary file. See ...
5
votes
2
answers
199
views
Evaluate large file with ^H and ^M characters
I have a logfile that contains many ^H and ^M characters, as the process that produces this file updates a text based progress bar.
When using cat the output is evaluated and appears human readable ...
1
vote
1
answer
499
views
Disable wake on usb after hibernation
Problem: I hibernate the computer at night and my cat wakes it by stepping on the keyboard. Yes, hibernate a.k.a. suspend to disk, with systemctl hibernate. Not suspend to ram. I used to think that, ...
-1
votes
2
answers
137
views
Find directories and merge files
So I have a file system of thousands of subdirectories in the form
304880.US
906T89.DE
032848.UK
023455.UKREGRESS
:
Sometimes inside the folders there are other folders called 1, 2 and 3.
Each end-...
1
vote
1
answer
57
views
How can I email a terminal session typescript without raw data?
I have a bash script that tries to kill two birds with one stone by running commands with script -c and writing the output to a log file so that I can monitor the progress, then email myself the ...
0
votes
1
answer
300
views
Use output of cat with split command and specified output directory
I'm trying to split a long csv into files of 500 lines each. I want the output files in a specific directory, and I want to leave off the first line of the csv.
I can use split and leave off the ...
0
votes
0
answers
28
views
Concatenation script is not working as expected [duplicate]
I have the following script that is concatenating files in a directory in a particular fashion. I did some testing on a toy example and it is not doing what I thought it was doing.
First, to describe ...
2
votes
1
answer
136
views
How to properly use tail to concatenate all hidden files [duplicate]
Issue
I want to be able to :
concatenate all files in a directory (regular and hidden),
but I would also like to display the title of each file at the beginning of each concatenation.
I found some ...
5
votes
3
answers
870
views
Pipe globs to ls
Contents of file filelist:
/some/path/*.txt
/other/path/*.dat
/third/path/example.doc
I want to list those files, so I do:
cat filelist | xargs ls
But instead of expanding those globs, I get:
ls: ...
1
vote
1
answer
83
views
cat command overwritten
By error I have execute "sudo nano cat filepathxxxx" and somehow I change the content.
The cat command is no longer working and I can't install it I tried to execute "yum install ...
3
votes
1
answer
219
views
Bash script : Cat multiple lines in file containing “$” characters [duplicate]
I'm doing a script to auto-install some stuff including a nginx web server.
I'm creating the nginx conf file like this :
cat >/etc/nginx/sites-available/bookstack.conf <<EOL
server {
listen ...
2
votes
1
answer
505
views
Why am I seeing % as the line end when running cat file cmd [duplicate]
This really confused me, when I do a cat cmd, I always see something like % at the end of a file, but if I open the file on editor or sublime, it is gone. So how to make sure my file is in a correct ...
0
votes
2
answers
255
views
Listing PCI Devices By Reading From File (Instead of lspci Command)
I need to read PCI device information from files. But it gives unusable output when I use command like that:
cat /proc/bus/pci/05/00.0
Output:
�h��
How could I fix this?
OS: Debian-like Linux x64, ...