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
0
votes
1answer
24 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 ...
2
votes
2answers
200 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. ...
56
votes
1answer
3k 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 ...
0
votes
2answers
134 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 ...
1
vote
1answer
237 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?
4
votes
2answers
67 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 ...
1
vote
2answers
617 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 ...
0
votes
1answer
364 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 >> ...
3
votes
2answers
220 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 ...
4
votes
1answer
359 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 ...
1
vote
2answers
61 views

Fully show all files in a directory — but with some spacing between them

In CentOS with Bash 3.2.52 I desire to fully-show all files in say current dir: cat * All files' outputs are displaying but they are totally juxtaposed one to another... I lack some cosmetic ...
-1
votes
1answer
978 views

How to read a file using sudo? [closed]

As part of an lab that I am doing titled "sudo", one of the questions is, "What is the password in the secret.txt file?". When I try cat secret.txt I get a permission denied message. When I try sudo ...
5
votes
1answer
1k views

cat and pipe vs. redirection [duplicate]

What's the difference between these two commands? cat /proc/uptime | awk '{print $1}' < /proc/uptime awk '{print $1}' Specifically, how does the second command work? Doesn't the redirection ...
-1
votes
2answers
230 views

How to concatenate only identical file names within two folders to one file?

I have fasta.qz sequence files with identical names, but in two different folders that I need to concatenate (concatenate always those two with identical names only!). The directory structure looks ...
0
votes
1answer
256 views

Ubuntu bash echo “$PASSWORD” | sudo -S WID=$(cat /var/lib/FILE)

/var/lib/FILE root:root 0600 (One line of text) How can I read the /var/lib/FILE into $WID echo "$PASSWORD" | sudo -S WID=$(cat /var/lib/FILE) not working for me.
-1
votes
1answer
3k views

Why does echo <<EOF … EOF not work [duplicate]

Just wondering if anyone can explain why this works: echo `cat <<EOF {"branch":"foo","value":"bar"} EOF` but this doesn't: echo <<EOF {"branch":"foo","value":"bar"} EOF (the second ...
1
vote
1answer
85 views

Copying files based on input list, special characters in file names

This is based on the question here. Problem: I have a .txt file listing file names I want to copy to the folder newfolder in the shell (Mac Terminal). Approach, where filelist.txt contains file ...
-5
votes
1answer
194 views

How to append file2 to file1 without changing their content, then output the result in file3

I have file2 and file1. I want to append file2 to file1 but without changing file1. I want to put the output in anew file file3. If I used cat file2 >> file1 this changes the content of file1.
0
votes
2answers
66 views

answering command automatically - performing cp operation between answers [closed]

The idea is that I want to execute a command, then it asks for a file name to process, and after it is done with processing, it outputs an image with the name prediction.png, it asks for the next ...
-2
votes
1answer
101 views

What is the difference (if any) between “cat input | tee > output” and “tee < input > output”?

I obtained the following: $ time $(tee < infile > outfile) real 0m14.721s user 0m0.094s sys 0m2.629s $ time $(cat infile | tee > outfile) real 0m8.931s user 0m0.123s sys 0m3.168 Is that ...
0
votes
1answer
61 views

using cat command to copy a file's contents to all files under a directory (recursively) [closed]

How could we use cat command to copy a file's contents to all the files under a directory (recursively -I mean each and every file)?
0
votes
2answers
579 views

Why the output of “cat a.out” is some weird text, instead of binary? [duplicate]

We all know "a.out" is file-format used to denote object code(binary) and is abbreviated form of assembler output, then cat a.out should also give us binary but why this doesn't happens? I am ...
1
vote
0answers
20 views

Data loss over ttyACM* in Ubuntu 14.04 whereas success on Ubuntu 16.04 when “cat” command is used [duplicate]

I have a development board which will have 3 ACM interfaces when connected to Ubuntu host and i want to transfer data from Host to Device over ttyACM3. I have followed the following procedure for ...
3
votes
1answer
909 views

cat on big files does not work

I'm trying to concatenate four big files in two. The files *_1P.gz contain the same amount of lines as the corrisponding *_2P.gz. The files A_1P.gz and A_2P.gz both contain 1104507560 lines. The ...
1
vote
1answer
37 views

Why raspbian lite powers off when doing `sudo cat /dev/char/10:130`?

I did on a terminal sudo cat /dev/char/10:130, which in the uevent has name of watchdog, and it outputs a message from the kernel saying that watchdog did not stop !, and after a couple of second it ...
1
vote
0answers
29 views

PING token missed after un-successful Bulk OUT transfer

I'm trying to send a large amount of data(~15 Mb) from Host to Device over ttyACM3. I have used "cat" command for sending the data from host. Host side: cat ./pattern.bin > /dev/ttyACM3 Device ...
2
votes
0answers
188 views

Data loss over ttyACM* when 'cat' command is used for data transfer

I have a development board which will have 3 ACM interfaces when connected to Ubuntu host and i want to transfer data from Host to Device over ttyACM3. I have followed the following procedure for ...
0
votes
0answers
74 views

How to convert visible control characters back to non-printing characters (opposite of 'cat -v')?

Given the content of the file which was the result of cat -v conversion such as: M-*M-;M-LM-]M-n How can I convert back the file to the original binary format? For example, given the following ...
0
votes
1answer
131 views

Run fail2ban-regex by piping with zcat?

Normally running the command would go like this: $ fail2ban-regex /var/log/ningx/access.log \ /etc/fail2ban/filter.d/nginx-noscript.conf -v However, I have multiple files that I'd like to parse ...
5
votes
1answer
633 views

What's the difference in these commands - cat piped to dd and just cat? [duplicate]

I'm curious to know the difference between these two commands in Linux: $ cat ./boot.bin ./kernel.bin /dev/zero | dd bs=512 count=2880 of=devos.img and $ cat ./boot.bin ./kernel.bin > devos.img
0
votes
2answers
269 views

How to I tail the STDOUT of a cat command [duplicate]

Let's say that I start a cat process to wait for some input. e.g., $ cat > out.log In another terminal, I can identify its PID and feed data into its File Descriptor 0 (zero = STDIN), like this: ...
9
votes
2answers
1k views

How can I print contents instead of file name from using linux find command?

I have thousands of unl files named something like this cbs_cdr_vou_20180624_603_126_239457.unl. I wanted to print all the lines from those files by using following command. but its giving me only ...
0
votes
1answer
299 views

Cat/grep just the lines with single ip

I have a file something like this Script http://127.0.0.1/ blabla 127.0.0.1 Script 127.0.0.2/index.html bla bla 127.0.0.2 Script 127.0.0.3/contact bla bla Script 127.0.0.4/settings bla bla 127.0.0.4 ...
1
vote
0answers
597 views

Counting User Agent visits from the access log for just the last 30 days

I'm trying to print a list of the most frequent visits from User Agents from the Nginx access log. I have so far come up with this: cat /var/log/nginx/access.log | awk -F\" '{print $6}' | sort | ...
5
votes
2answers
603 views

Errors on cloning disk with cat

I wish to clone a large disk (a 500GB SSD, for what it's worth), and I am leaning toward using cat, as suggested by Gilles here. But what gave me pause is that I do not really know what cat does upon ...
0
votes
3answers
2k views

How to concatenate files from different sub-directories?

I have a large folder containing many sub-directories each holding many .txt files. I want to concatenate all of these files into one .txt file. I am able to do it for each of the sub-directories with ...
3
votes
2answers
193 views

how to perform a calculation on the output of cat and then format it [closed]

I don't know shell scripting at all, but I have this cat /sys/class/power_supply/BAT0/power_now which gives me the output in milliwatts, which i would like to format as watts and use in watch watch ...
5
votes
4answers
179 views

cat last 5 files in a dir

I have a directory with filenames of the format $date.txt. I would like to cat 5 latest files from it. Is there a more elegant solution to that, than for f in 2*.txt; do echo $f; done | tail -5 | ...
0
votes
1answer
48 views

convert ncurses binary dump into text

I have a ncurses dump (with for example screen recorder from GNU screen) and I would like to convert it into text (there are some conversations in it, some lists and other things, all text, but ...
2
votes
1answer
249 views

'ambiguous redirect' error from Bash

I have three directories a,b,c and each have a file named old.txt I would like to copy the contents of the file new.txt to each of these files. My approach is $ cat < new.txt > {a,b,c}/old.txt ...
12
votes
3answers
2k views

Why does “cat {foo}” not output foo, but “cat {foo,bar}” does?

I was trying to concatenate text files in sub-folders and tried: cat ./{mainfolder1,mainfolder2,mainfolder3}/{subfolder1}/book.txt > out$var However this did not return anything. So, tried adding ...
-1
votes
1answer
636 views

bash redirect to file if file does not exist

I have this bash code: if [[ ! -f "$HOME/.oresoftware/package.json" ]]; then cat "node_modules/@oresoftware/package.json" > "$HOME/.oresoftware/package.json"; fi but is there a way ...
2
votes
2answers
207 views

Split and merge - with DVDs!

Say I have a large file called foo.tar.xz. I split the file into parts of just under 4.7GB each, using split -b 4689887232 foo.tar.xz foo.tar.xz., which gives me files named foo.tar.xz.aa, foo.tar.xz....
0
votes
1answer
48 views

extracting rows from a file that match with the second file and merge them as single file

I have a file contains some positions, head positions 142541687 142541814 142541910 142542976 142544533 142546366 142548674 142560386 I have another folder contains of 1800 files, each file belongs ...
0
votes
2answers
56 views

How to efficiently remove the 2 byte signature at the beginning of a 10mb log file and cat at same time

Ubuntu 16 I currently use cat to pipe a logfile from a remote machine to a website log viewer. The logfile has a two-byte signature at the beginning which tells it the file is 16bit or 8bit. if I ...
1
vote
1answer
51 views

How to wrap a string around large gzip file?

I have a large (several GB) xml file that is missing a root element. I might use cat on ubuntu to wrap around a <root> element around the content. How can I achieve this without having to ...
1
vote
2answers
1k views

Line Number for all non-blank lines?

Kind of amused here, I'm trying to pass the prereqs to get into the Udacity Course on High Performance Computer Architecture by Georgia Institute of Technology For the life of me I can't figure out ...
2
votes
1answer
2k views

Why can't an input file be an output file?

Specifically in the case of cat x y > y and cat x >> x where x and y are files. What would happen if I didn't get a "input file is output file" error? Basically, why am I not allowed to run ...
0
votes
3answers
50 views

multiple concatenation of strings without writing intermediate files

I would like to extract parts of some files and concatenate them into another but without writing an intermediate file. For instance: $ cat textExample.txt Much I marvelled this ungainly fowl to ...
0
votes
2answers
1k views

hide output of command while using cat and tee

I have a text file that contains some IPs. I want to copy the contents of this text file into /etc/ansible/hosts without showing the output on the terminal (as shown in example 2). Note: root user is ...