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
2 votes
1 answer
2k 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; ...
Salines's user avatar
  • 123
6 votes
2 answers
13k 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....
user avatar
0 votes
1 answer
714 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/' ...
Bhaven Parakh's user avatar
1 vote
2 answers
3k 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 ...
Lucas's user avatar
  • 11
2 votes
3 answers
2k 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 ...
Alexander Mills's user avatar
0 votes
2 answers
146 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-...
Ali Haydar Doğan's user avatar
0 votes
1 answer
2k 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 #...
Molly_K's user avatar
  • 161
2 votes
1 answer
2k 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 ...
weltraumfahrer_x's user avatar
1 vote
1 answer
102 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 ...
Cosinus's user avatar
  • 111
0 votes
2 answers
662 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?
user9371654's user avatar
6 votes
3 answers
625 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 ...
user2740's user avatar
  • 291
2 votes
4 answers
7k 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 ...
user avatar
0 votes
1 answer
461 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 ...
welkin's user avatar
  • 11
0 votes
1 answer
1k 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 ...
user977828's user avatar
9 votes
2 answers
7k 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 ...
Yves's user avatar
  • 3,301
3 votes
4 answers
5k 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 ...
user9371654's user avatar
6 votes
6 answers
12k views

What is a quick way to count lines in a 4TB file?

I have a 4TB big text file Exported from Teradata records, and I want to know how many records (= lines in my case) there are in that file. How may I do this quickly and efficiently?
Santosh Garole's user avatar
0 votes
0 answers
253 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 ...
Owen's user avatar
  • 9
4 votes
3 answers
6k 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 ...
Eli's user avatar
  • 143
0 votes
1 answer
2k 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, ...
Opifex's user avatar
  • 420
-1 votes
1 answer
169 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 ...
Tapal Goosal's user avatar
0 votes
1 answer
1k 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 ...
Avery Alejandro's user avatar
0 votes
2 answers
47 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-...
Duns's user avatar
  • 111
2 votes
3 answers
917 views

Why can I not access a file named `-` even when quoting the filename? [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 ...
Jhdoe's user avatar
  • 123
2 votes
4 answers
1k 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 ...
gizmo's user avatar
  • 33
0 votes
1 answer
203 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....
Mackes93's user avatar
1 vote
1 answer
2k 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 ...
Rak kundra's user avatar
1 vote
2 answers
1k 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 ...
LocalHost's user avatar
  • 489
0 votes
2 answers
220 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 ...
bohan Chen's user avatar
-2 votes
1 answer
1k 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 ...
user1529413's user avatar
0 votes
1 answer
1k 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. ...
student's user avatar
  • 18.3k
0 votes
1 answer
111 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?
Born vs. Me's user avatar
0 votes
2 answers
6k 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 ...
randallgann's user avatar
0 votes
4 answers
783 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....
xyz_scala's user avatar
  • 131
2 votes
2 answers
627 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 ...
hoytpr's user avatar
  • 31
-1 votes
2 answers
446 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
youngchaw's user avatar
1 vote
2 answers
433 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 ...
Molly_K's user avatar
  • 161
3 votes
1 answer
2k 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 ...
Dave's user avatar
  • 275
0 votes
1 answer
2k 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 -...
C. Cristi's user avatar
  • 228
-3 votes
1 answer
2k 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 ...
Tim's user avatar
  • 102k
0 votes
1 answer
31 views

combine files that share a similar characters

I have a folder with hundreds of files. These files are score files for 26 environmental variables across 510 genotype files. For example in the examples below, _s2. is the second environmental ...
Anna1364's user avatar
  • 1,026
2 votes
2 answers
4k views

cat is stuck on a specific file

I have a python script that generates a file (cap.pcap). when I execute cat on it, it gets stuck forever (doesn't display anything). I tried to run: The commands file, hd and vi. They work properly. ...
zeralight's user avatar
  • 121
54 votes
1 answer
5k views

Change permisions of a file with my cat's help

root@system:~# less myfile -bash: /bin/less: Input/output error The root filesystem is dead. But my cat is still alive (in my memory): root@system:~# cat > /tmp/somefile C^d root@system:~# He's ...
loopbackbee's user avatar
  • 4,632
0 votes
2 answers
1k views

How to stop cat command from outputting file name if it's piped to another command?

I'm trying to learn regular expressions, and so I created a file with some characters in it. When I use the cat command and pipe it to rgrep command with an argument to filter out text, the resulting ...
Skaper's user avatar
  • 3
1 vote
1 answer
3k views

Store a file on server with curl command using post method like scp? [duplicate]

Like this: cat tmp.txt | curl --post domain.com/file-to-store I want to store content of tmp.txt on my machine to server using only terminal. Is it possible?
Akhil's user avatar
  • 1,290
5 votes
2 answers
267 views

How does `cat`'s I/O model differ from that of other utilities?

From the output of stdbuf --help (GNU): Usage: stdbuf OPTION... COMMAND Run COMMAND, with modified buffering operations for its standard streams. ... NOTE: If COMMAND adjusts the buffering of its ...
Sam's user avatar
  • 361
2 votes
2 answers
8k views

make find search in alphabetical order

I am currently using a short find command in order to search a number of directories (and sub-directories) for files ending in "tex" and then catting them into one coherent text. The command that I ...
miri queer's user avatar
7 votes
3 answers
13k views

Diff outputs "binary files <file1> <file2> differ" but not the usual detail output

I would like to compare two files - "orienv" and "currenv", using the command diff. The way I had created the two files was as follow: Createing the "currenv" file $cat /proc/1/environ >> ...
Tran Triet's user avatar
5 votes
2 answers
2k views

Concatenate multiple zipped files, skipping header lines in all but the first file

I have a collection of gzipped files that I want to combine into a single file. They each have identical format. I want to keep the header information from only the first file and skip it in the ...
SethMMorton's user avatar
7 votes
1 answer
9k views

How to `touch` and `cat` file named `-` [duplicate]

How do I use GNU touch to update a file called -? How do I use GNU cat to display a file called -? I'm running: % cat --version | head -n1 cat (GNU coreutils) 8.29 % touch --version | head -n1 ...
Tom Hale's user avatar
  • 30.5k

1
3 4
5
6 7
14