I'm trying to cat a bunch of files, some of which may not exist. Now that's ok if some of them don't exist, but I don't want cat to return an error in this case, if possible. Here's my call:
zcat *_max.rpt.gz *_min.rpt.gz | gzip > temp.rpt.gz
When this command is run, either a bunch of files matching *_max.rpt.gz will exist, or *_min.rpt.gz will exist. If the other doesn't exist, I don't care, I just want to concatenate what I can. But I'm getting an error message which stops the rest of my code from running.
Anything I can do? Thanks.
cat command allows us to create single or multiple files, view content of a file, concatenate files and redirect output in terminal or files.
Type the cat command followed by the file or files you want to add to the end of an existing file. Then, type two output redirection symbols ( >> ) followed by the name of the existing file you want to add to.
The key takeaway from this section is that we use cat > FILENAME to create or overwrite a file. Additionally, we can use cat >> FILENAME to append to a file that's already there. Then after typing in the text we want we use CTRL + D to exit the editor, return to the command line, and create the file.
Cat is short for concatenate. This command displays the contents of one or more files without having to open the file for editing. In this article, learn how to use the cat command in Linux. A system running Linux. Access to a terminal window / command line.
[ -f file.txt ] && cat file.txt
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With