Cat command, quick recap

About writing shell scripts and making the most of your shell
Forum rules
Topics in this forum are automatically closed 6 months after creation.
Locked
nathanjh13
Level 3
Level 3
Posts: 181
Joined: Mon Mar 22, 2010 2:48 pm

Cat command, quick recap

Post by nathanjh13 »

I'm combining hundreds of text files (phone memos in txt format) into one file. Many are only a handful of words long. I can do this easily enough with cat but there's no separator at all between the entries and it's a big mess, even using -n etc.

thanks
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
User avatar
xenopeek
Level 25
Level 25
Posts: 29615
Joined: Wed Jul 06, 2011 3:58 am

Re: Cat command, quick recap

Post by xenopeek »

This topic has various ways to add a separator between files that you combine: http://superuser.com/questions/103530/how-can-one-join-files-with-seperating-data-in-bash. First answers uses sed magic instead of cat. Second answer captures the cat action in a loop, and adds a separator with the echo command.
Image
Locked

Return to “Scripts & Bash”