Question regarding Cat


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Question regarding Cat
# 1  
Old 12-28-2011
Question regarding Cat

Can we concatenate say,

I have a few files prefixing with 2009...

So now i want all the 2009 files into one single file..


Can this be achieved????
# 2  
Old 12-28-2011
Yes. Just bear in mind that "cat" literally concatontates the contents of the files and the new file does not contain any file names or file separation whatsoever. If you need to preserve the separation of files, consider use "tar".

Code:
cat 2009* > file_containing_all_of_2009

# 3  
Old 12-28-2011
Thanks Methyl...Can you also let me know How this "TAR" would exactly work in my scenario as well..Appreciate your help.
# 4  
Old 12-28-2011
Obviously read "man tar" and be sure that you understand any limitations which may apply to your system. We know nothing about your system or the size of your files or the quantity of file or the reasoning behind your process.

This command creates a simple "tar" archive: Beware that this does not work on every Operating Systems and can collapse if there are too many files (e.g. with AIX).
Code:
tar -cvf file_containing_all_of_2009.tar 2009*

# 5  
Old 12-28-2011
For AIX, you also get a -L flag on the tar command, so as a two step processes:-
Code:
ls 2009*> list_file
tar -cvf file_containing_all_of_2009.tar -L list_file

... or if that fails because 2009* expands too long, then you can
Code:
find . -name "2009*" > list_file
tar -cvf file_containing_all_of_2009.tar -L list_file

I hope that this helps.



Robin
Liverpool/Blackburn
UK
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Homework & Coursework Questions

Cat/File Descriptor Question

For the command below, I need to understand what exactly the command does and provide an examples for which the output will be saved to file save2... From my understanding, if the file provides an error in the first half of the pipe, it'll save to save1 and will never give an error to save to... (2 Replies)
Discussion started by: ayz649
2 Replies

2. Shell Programming and Scripting

Simple cat and echo question

Apologies, probably a really simple problem: I've got a text file (nh.txt) with this in it: user1 email1 email2 user2 email1 email2 etc With the following basic script: for tline in $(cat nh.txt) do echo "**********" echo $tline done ... (3 Replies)
Discussion started by: nelmo
3 Replies

3. Shell Programming and Scripting

cat question

hello! why this works? cd /home/user cat * | ecasound -i stdin -o jack and this doesn't? cd /home/user/somedirectory cat * | ecasound -i stdin -o jack somedirectory are full with exe files which are the best source for this sort of noise thing (10 Replies)
Discussion started by: karlhungus
10 Replies

4. Shell Programming and Scripting

cat question

Can any one guide me how can i accomplish this by script i continuously receive files via our ftp server into a certain folder is there a way i can take those files cat it to a new file by hour and create a new file when new hour starts? (4 Replies)
Discussion started by: shehzad_m
4 Replies

5. Shell Programming and Scripting

Easy cat question

I am having problems getting a list of filenames that I want from a directory. example: I have 3 files - filename.xxx.20110505.123030 filename.yyy.20110505.123030 filename.zzz.20110505.123030 There may be multiple xxx,... (3 Replies)
Discussion started by: Drenhead
3 Replies

6. OS X (Apple)

Question about cat and echo

Hello, I am trying to send text to a USB to serial adaptor and then to an external speech synthesizer. I tried using the cat and echo commands with no luck. I have gotten some audio output from my synthesizer using Kermit a terminal emulator, so I am pretty sure my synthesizer and my USB to serial... (1 Reply)
Discussion started by: jamesapp
1 Replies

7. Shell Programming and Scripting

Question regarding cat command

Hello Friends, I have a question, i am trying to write a shell script in the bash shell. #!/bin/sh NAWK=/bin/nawk AWK=/bin/awk FIX_XML_PATH=/home/administrator/testfix/fix/ Y=`ls $FIX_XML_PATH | grep xml` echo $Y cat $Y in this case when i do the echo $Y command it gives me the... (11 Replies)
Discussion started by: asirohi
11 Replies

8. Shell Programming and Scripting

question about cat in script

hi all i have some script echo $$ > process-id d='cat process-id' if test-s "TMP"$d then echo "serv1" else echo "serv2" fi the variable d should contain the number of the process, instead of that it contains 'cat process-id' how shall i do that the d will contain only the number?... (6 Replies)
Discussion started by: naamas03
6 Replies

9. UNIX for Dummies Questions & Answers

Difference between cat , cat > , cat >> and touch !!!

Hi Can anybody tell the difference between Difference between cat , cat > , cat >> and touch command in UNIX? Thanks (6 Replies)
Discussion started by: skyineyes
6 Replies

10. Shell Programming and Scripting

strange cat question.

Does anyone know what the microprograms behind cat (and other commands) are like? In what language are those programs designed? Is their source available somewhere? No particular reason, just wondering. I know it's a bit strange... (3 Replies)
Discussion started by: sanchopansa
3 Replies
Login or Register to Ask a Question