Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [cat]

cat is a standard Unix utility used for concatenating files or printing specific file on the standard output.

-1
votes
2answers
48 views

Display contents of the file searched by grep or find command [closed]

I have lots of directories in a certain directory and I am trying to find a specific file present in there. I used grep command recursively and was able to locate the file being present in there, but ...
0
votes
0answers
16 views

How do I monitor a Socat mounted COM Port device for a specific Char Delimiter?

I have a code like the following: cat -v -e /dev/tty03 | grep --line-buffered '^F' | while read do echo "Line Found" done How can I setup a timeout for the above While Loop. I want the "while" ...
0
votes
1answer
29 views

Can't seem to concatenate multiple files in different directories

I'm trying to concatenate multiple files together that are in different directories using the following command: ~$ find . -name ‘*.text’ -exec cat {} >> combined.text \; However it doesn't ...
0
votes
1answer
16 views

replace/remove text (sed) by a file

I want to replace/remove text all files by a file. $ echo "_uU_%UHY%^GSSD$%GWRW$T#wf4werwefF$fW#$wfdd%6blahblahblah" > pattern.txt $ sudo grep -rl "_uU" . | xargs sed -ie s/$(cat pattern.txt)//g ...
1
vote
1answer
35 views

How to cat named pipe without waiting

If there is nothing in a named pipe and I do: cat my_named_pipe it will wait until data arrives. Is there a flag I can use to exit immediately if there is no data to be read? Or perhaps a command ...
2
votes
1answer
36 views

`cat -v` for non-printing non-ascii UTF characters

cat has a -v option which converts non-printing characters to their caret notation (which is useful if we don't want the terminal to interpret the control characters literally in cat output). But ...
2
votes
1answer
57 views

Pass variable to cat [duplicate]

I have only one variable in bash script ${PHP_V} and trying to pass in nginx config file like: cat <<'EOF' > /etc/nginx/sites-available/default server { listen 80 default_server; ...
0
votes
1answer
33 views

Display line number in head and tail command like `cat -n`

cat without -n user@linux:~$ cat /etc/sysctl.conf | head -4 # # /etc/sysctl.conf - Configuration file for setting system variables # See /etc/sysctl.d/ for additional system variables. # See sysctl....
0
votes
1answer
25 views

I am not able to update a variable through sed command

I have assigned two variables but not able to update x=$(cat /scratch/env.properties | grep ConfigPath) y=$(ConfigPath=/scratch/a/b) then sed to replace ConfigPath in env.properties sed 's/$x/$y/' ...
5
votes
2answers
73 views

What determines whether backspaces show up in a file created with cat?

I just noticed that I've seen different behavior across different systems when creating a quick test file (e.g. with sample input) via cat and redirection. Here are the steps to see what I'm talking ...
1
vote
2answers
114 views

find n most frequent words in txt file using the terminal but with the cat, “grep .” and tr -d “/r” commands

I would like to find n most common words in a text file but with the following conditions: cat to get the file. grep . to get the words. tr -d '/r' to get rid of new lines. I've managed to get ...
0
votes
3answers
49 views

create single string argument using heredoc or other technique

I am trying to execute a script on remote servers, passing the script as the last argument ntrs exec-all-ubuntu --exec `cat << 'EOF' echo "$(pwd)" echo "$foobar" EOF` The problem is that ...
0
votes
2answers
44 views

How to delete string other than pattern?

I have a m3u file as below. I want to delete all strings except the pattern and next first line. or save the pattern and the next first line as another file. Patterns group-title="TR ULUSAL" , group-...
0
votes
1answer
34 views

echo strings but extra question mark was added to the output

Strange "?" got added to the filename output. SCRIPTS="/path_to_script/" SUMMER=`cat /path_to_file/summer.txt` for i in ${SUMMER}; do cat <<- EOF > $SCRIPTS/20190430_$(echo ${i})_step4.r #...
2
votes
1answer
23 views

How I can read content of the ssh key file using a path read from a file?

I need to read content of the ssh key using the given path resides in a file like following: my ssh private key is: ~/.ssh/firstname.lastname When I call cat ~/.ssh/firstname.lastname in terminal on ...
1
vote
1answer
71 views

`cat` behaves strangely on a mounted virtio directory

When I'm in a mounted directory (9p) on my gentoo-guest and do the following: TMPDIR='./foo' # The directory './foo' exists and the name 'TMPDIR' is important cat <<EOF hello world EOF I get ...
0
votes
2answers
37 views

How to extract lines knowing start and end lines

I have a file with 1 million lines. I want to extract lines from line 10001 to 500000 How to do this?
5
votes
3answers
520 views

How to display lines in a file like ls displays files in a directory? [duplicate]

I have a long file with short lines (one word) f that I would like to inspect. It would fit on the screen if it wasn't for the newlines. If the data was already arranged in columns I could just do ...
1
vote
4answers
615 views

Why use cat to view a file? [closed]

It seems that the purpose of cat is to concatenate several files. However, many people still use cat instead of less (or a similar program like more) to display a file. See, for example, the GNU m4 ...
0
votes
1answer
48 views

Why do cat and more wrap lines differently?

It seems that more adds line breaks, whereas cat does not. As a result cat results will change to fit the terminal window if I resize the window, whereas more results stay put with the line breaks ...
0
votes
1answer
52 views

“nohup cat” — write the complete content to the log file rather to concatenate file

I used the below command nohup cat fastp-filtered/OZBenth*_R1.fastp.fq.gz > fastp-filtered-merged4racon/merge_R1.fq.gz > merge_R1.out.log 2>&1 & but unfortunately, the output went ...
7
votes
2answers
2k views

cat shows nothing

My team is working on a CI environment. A ko file, named x.ko, is always generated from the CI environment at a regular time everyday and its type is ELF 64-bit LSB relocatable. Today, I found that ...
2
votes
4answers
260 views

How to copy the rest of lines of a file to another file [duplicate]

I have the string xyz which is a line in file1.txt, I want to copy all the lines after xyz in file1.txt to a new file file2.txt. How can I achieve this? I know about cat command. But how to specify ...
0
votes
2answers
74 views

Is there a quickest way to count lines in file which is of 4TB in linux?

Actually I have 4 TB of Txt file as Exported from Teradata records and I want to know How many records are there in that file.
1
vote
0answers
35 views

Getting awk value and outputting to a file [duplicate]

I need to get a value from a log file which I am getting using awk at the moment. I can get the number printing on the console but when I try to put that value into a new file nothing happens. Here is ...
3
votes
3answers
520 views

insert EOF statement before the last line of file

I want to insert this cat <<EOF >> /etc/security/limits.conf * soft nproc 65535 * hard nproc 65535 * soft nofile 65535 * hard ...
0
votes
1answer
82 views

cat shows file contents, gedit and vim show blank file

I was planning on building a current logging device with an Arduino, and tried starting off with the basic SD-card write example from the Arduino IDE sketchbook. The Serial console showed no errors, ...
-1
votes
1answer
86 views

Can't see the contents of a data file in terminal

I have downloaded a number of input files from the NASDAQ website (for example ftp://emi.nasdaq.com/ITCH/01302018.NASDAQ_ITCH50.gz) After decompressing (I double click on a Mac) I can't see the file ...
0
votes
0answers
22 views

Different behaviours of sudo [duplicate]

I created a file with sudo like this: sudo touch abc.txt Which understandably set the owner to root. Now when I try to edit the file via vi using sudo, it works: sudo vi abc.txt #works But when I ...
0
votes
1answer
61 views

How to merge files in Linux while deleting the source files

I have 2 large files (of about 27 GB each), which I need to merge. They were originally one whole ZIP file, but I split it. The problem with the cat command is that it creates a new file which has the ...
0
votes
2answers
23 views

cat: append a text file in another folder as Dolphin action

How can I append an md-file to another md-file in a subfolder as Dolphin action? I tried cat %U >> subfolder-name/%u, but I get this error message: cannot create subfolder-name//path/to/md-...
2
votes
3answers
643 views

Why can I not access a file named `-` when quoting? [duplicate]

I have a file called -. I want to display its contents. One way is to do cat ./- since cat - reads from standard input. However, why are cat "-" and cat '-' also interpreted by the shell as cat -?
2
votes
4answers
84 views

Combine large amounts of files inside a directory

I have a large amount of files within a single directory, currently 10,804 files. the amount of files can float between 5 and 100,000. I am looking for a way to combine every 250 separate files into ...
0
votes
1answer
26 views

Merge Lines that start with special Character into new File

the following Situation: I have about 2000 Files that are named like "dens_Run0_set0.#" where # is some Number and they are filled like this 1 0 1.000000e-01 6.3043370127282594e-01 -9....
0
votes
0answers
17 views

Replace the part of lines in multiple files matching a pattern with lines from another file in order [duplicate]

I want to replace the part of lines matching a pattern from multiple files from the lines in order from another file, i have up to 500 txt files, with structure: test1.txt, test2.txt, test3.txt... ...
1
vote
1answer
248 views

Removing control M characters from a given file and to remove newline character if it is the only character in the entire file

We have a file named as abc.txt and its a empty file. Due to some junk or control M characters, the file size is populated as 5 byte file. In order to have clean file we are using dos2unix command to ...
1
vote
2answers
59 views

navigating forward in more pager using f

It is given in the man page of more that f is used to skip forward k screenful of text(default to 1).I saved a very long file using cat and used more to show it on the screen page by page but when i ...
0
votes
2answers
51 views

How to use bash cat * to wrap? [duplicate]

ls /proc/ 1 10984 11246 131 144 167 2099 31788 4805 5375 6762 7594 8111 8722 consoles 10 10993 11247 1314 14400 168 21 32 4807 5379 6771 76 8112 ...
-3
votes
1answer
135 views

What is the equivalent (programmatically) of cat /dev/something > file.txt [closed]

I'm copying a video from a camera stream using a command cat /dev/video0 > file.mpeg This works perfectly, however I want too break up the file into smaller chunks... So I've been waiting pressing ...
0
votes
1answer
118 views

Pipe file containing list of images to sxiv and reflect changes immediadly

Suppose I have a file images.txt which contains for example image1.jpg image2.jpg image3.jpg Then I pipe the images.txt to sxiv and I want that the thumbnail view reflects the changes immediately. ...
0
votes
1answer
39 views

join all text files in subfolders in ubuntu into a single file

I have many folders/subfolders with text files in them. Is there any way to iterate all of the subfolders and join all the files into a single large file?
0
votes
2answers
97 views

How to let process continue running even after disconnecting ssh?

I have a Linux based router that I’m trying to “control” with a home automation controller. On my automation controller I’m able to utilize a ‘two way strings’ driver to send a string to the Linux ...
0
votes
4answers
201 views

grep and cut text from unstructured file?

From below 3lines I need to grep and cut jar file name only. How to grep jar name from the line and cut from there. Downloading:https://repo.maven.apache.org/maven2/org/springframework/spring-aop/5....
2
votes
2answers
51 views

Need to iterate through subdirectories, concatenating files, with an iterative number

I'm trying to concatenate files from three different subdirectories into one file. The names of the files in each subdirectory are exactly the same. I'd like to use a loop to iterate through the ...
-1
votes
2answers
60 views

How to print the first line which include special word [closed]

Print the first 123 below XXX AAA BCB DDD 123 123 XXX CCC 123 123 MSM 123
1
vote
2answers
28 views

How to echo content into a series of new file generated by cat

I would like to write a loop to generate 22 R scripts with contents generated in echo. What went wrong in this loop that I could not get the 22 files with the corresponding content? I tested echo "i ...
3
votes
1answer
91 views

What does cat of a tar archive show? [closed]

I was doing a penetration testing capture the flag training exercise and found a file called "backup". I checked the file type of "backup" and saw it was gzip compressed. I decompressed it to a file ...
0
votes
1answer
319 views

How to take number of bytes transmitted and received from /net/proc/dev

I want to take the number of bytes transmitted and received from /proc/net/dev in this format: num_ofbytesTransmitted,num_ofbytesReceived. This was my approach: cat /net/proc/dev | grep enp0s3 | cut -...
-3
votes
1answer
124 views

How does `cat` work so that it allows reading a file line as an array element? [duplicate]

In bash, we can read an file into an array, so that each line in the file becomes an element of the array. $ arr=( $(cat myfile) ) I was wonder how cat works so that it allows reading a file line as ...
1
vote
0answers
43 views

How should I output the contents of a file to terminal without using cat? [duplicate]

I've been hearing talk of UUOC, "Useless Use of cat", lately, and it seems like the consensus is that cat should really only be used when concatenating multiple files. This has me wondering, is there ...