Questions tagged [cat]

The cat command is a standard Unix program used to concatenate and display files. The name is from catenate, a synonym of concatenate.

cat - concatenate files and print on the standard output.

The cat command is used for:

  1. Display text file on screen
  2. Read text file
  3. Create a new text file
  4. File concatenation
  5. Modifying file

Example

$ cat -n file #shows the content of a file, including the line-numbers(-n flag)

Concatenating two files into third file:

cat file1 file2 > output_file 

The purpose of cat is to concatenate (or catenate) files. If it is only one file, concatenating it with nothing at all is a waste of time, and costs you a process." This is also referred to as "cat abuse". Nevertheless the following usage is common:

cat filename | command arg1 arg2 argn
cat -- "$file" | grep -- "$pattern"
cat -- "$file" | less

can instead be written as:

grep -- "$pattern" "$file"
less "$file"

A common interactive use of cat for a single file is to output the content of a file to standard output. If the output is piped or redirected, cat is unnecessary.

Without two named files, the use of cat has no significant benefits.

Useful links

1519 questions
0
votes
0 answers

how to combine fasta files?

My question is regarding concatenating two gene sequences into a combined file. Here are four of example file…
upendra
  • 2,141
  • 9
  • 39
  • 64
0
votes
2 answers

sendmail with cat adding extra spaces in email body

When I try to read a file and send email using cat and sendmail, the email I receive has additional spaces between the letters of words in the text. My code: export MAILTO="sa@y.com" export SUBJECT="mydomain PREPROD MONITOR AT ${DATE}" export…
SSA
  • 73
  • 1
  • 9
0
votes
1 answer

cURL, cat, python and missing parts from a web page

I have downloaded a web page(charset=iso-8859-1) using curl curl "webpage_URL" > site.txt The encoding of my terminal is utf-8. Here I try to see the encoding of this file: file -i site.txt site.txt: regular file Now: the strange thing: If I open…
artBCode
  • 837
  • 10
  • 13
0
votes
4 answers

How to cat or echo everything between two words in a file

How to cat or echo everything between two words in a file ? eg df df Instance d f g end So I want everything between Instance and end Thanks
Roopak Vasa
  • 117
  • 1
  • 6
0
votes
3 answers

How to pass variables that are arguments in user defined functions to subfunctions in r

I have a general problem in understanding how to create a user defined function that can accept variables as arguments that can be manipulated inside the defined function. I want to create a function in which I can pass variables as arguments to…
RayR
  • 57
  • 1
  • 9
0
votes
1 answer

Concatenating multiple .txt in files in subdirectories

I have multiple .txt files in different levels of subdirectory. All txt files are in the final iteration, that is, there is no level with both .txt files and further directories. I want to concatenate them all into one new text file, but can't find…
Henry Brice
  • 280
  • 1
  • 2
  • 18
0
votes
2 answers

Setting a Variable = to a string in a text file

I am trying to place a line of a text file, directly in a mail function. The string has the ' ' around it in the text file. mailx -s "New Member" "cat ../address" A line in ../address is 'my-email@gmail.com' including the ' ' quotes. The cat…
user3386373
  • 129
  • 1
  • 1
  • 10
0
votes
1 answer

reading cat file passing to command not working properly

I have a file containing a list of process is input1 file proc1 proc2 b proc3 a I use the following command to read the file and pass on the content of the file to a variable and then do something for in in cat `input1`;do echo $i done It works…
theuniverseisflat
  • 861
  • 2
  • 12
  • 19
0
votes
2 answers

run cat command for all the files in the directory given in argument of the script file and out put with the name given as second argument

I run the following code for concatenating files in a directory given as the argument for the script file in bash for i in $* do cat $* > /home/christy/Documents/filetest/catted.txt done This produce the error cat:…
chris
  • 190
  • 1
  • 14
0
votes
1 answer

Copying files from local machine to remote HDFS cluster directly

I want to copy a file directly from my local Linux machine to a remote HDFS cluster i.e., I don't want to copy the file to the remote machine and then move it to HDFS using copyfromlocal command. For this, I have executed the following command which…
samvijay
  • 197
  • 5
  • 14
0
votes
1 answer

3Ds Max CAT animation

In character animation toolkit: I've created an animation in the absolute layer. How can I set rotation keyframes for the whole character? Example: In my abs layer, I have created a dancing animation. Apart from this, I would like my character to be…
Riko
  • 433
  • 1
  • 6
  • 20
0
votes
1 answer

How to implement squeeze functionality of 'cat' command using c?

The following is a part of my program trying to implement 'squeeze' or '-s' of 'cat' command using c. Now the main function uses argv and argc, which are analysed by using getopt function.'squeeze' function is called in main and 'stdin' and 'stdout'…
0
votes
1 answer

Read file from terminal input "cat" on C

I'm making a program that read CSV files based on the arguments of the C program called read-log example $ ./read-log file1.csv $ ./read-log file1.csv file2.csv nofile.csv But I also need my program to read files when using the unix command cat…
Ivan
  • 3
  • 1
  • 3
0
votes
2 answers

Unwanted empty lines using echo and cat

I want to add a line to the beginning of a text file. I have input.txt: line1 line2 line3 and want to add the line 'time/F:x1:x2' to end up with time/F:x1:x2 line1 line2 line3 I'm trying to do this with echo 'time/F:x1:x2' | cat -…
pengwing
  • 73
  • 8
0
votes
1 answer

Cat unix command multithread implementation

Hi im trying to implement faster cat than the one provided. My current implementation looks like this: #include #include #include #define BUF_SIZE 1024*1024*1024 char buffer[BUF_SIZE]; pthread_mutex_t mutex =…
Yetti
  • 327
  • 1
  • 4
  • 17