UNIX Cat All Files In A Directory

by on February 25, 2009 · 0 comments· last updated at February 25, 2010

How do I combine all text files in a directory into a single file and ftp that file to another server?

You can use cat command as follows:

 
cd /dest/dir
cat *.txt > /tmp/output.txt
# now send file using lftp ftp client
lftp -u username,password -e "cd /some/ftp/dir; put /tmp/output.txt; quit;" ftp.nixcraft.in
 

The following will find every text file in directory:

 
find /dest/dir -name "*.txt" -print | xargs cat >> /tmp/output1.txt
# now send file using lftp ftp client
lftp -u username,password -e "cd /some/ftp/dir; put /tmp/output.txt; quit;" ftp.nixcraft.in
 


You should follow me on twitter here or grab rss feed to keep track of new changes.

Featured Articles:

{ 0 comments… add one now }

Leave a Comment

You can use these HTML tags and attributes for your code and commands: <strong> <em> <ol> <li> <u> <ul> <kbd> <blockquote> <pre> <a href="" title="">

Tagged as: , , , , , ,

Previous Faq:

Next Faq: