LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   cat > list strip all lfd and replace with a space (https://www.linuxquestions.org/questions/linux-general-1/cat-list-strip-all-lfd-and-replace-with-a-space-488594/)

rioguia 10-01-2006 09:12 PM

cat > list strip all lfd and replace with a space
 
I need to make a list of files in a directory, and concatinate all the files on the list. I suspect that that a vi command, a script or a pipe could do this but I haven't been able to figure it out. Can someone help point me in the right direction? Here are the steps I have taken so far:

Step One
ls *.avi > list_of_avi.txt

The list_of_avi.txt contents look like this:

apple.avi
baby.avi
candy.avi

Step Two (help needed)
I want to strip the lfd (line feeds) and replace them with a space so that the file looks like this:

apple.avi baby.avi candy.avi

Step 3 (help needed)
cat contents of list_of_avi.txt so that all the files in the directory are put together like this

cat apple.avi baby.avi candy.avi > one_big_avi

macemoneta 10-01-2006 09:24 PM

Why not do it right; install transcode. As part of the package is the avimerge utility. In addition to being able to merge all the avi files easily, it can prevent the audio sync problems that can occur when joining with cat:

avimerge -c -o one_big.avi -i *.avi

konsolebox 10-01-2006 09:44 PM

if you still want to join with cat,

Code:

ls *.avi > list.txt
cat /dev/null > onebigfile.avi

IFS=$'\n'
for a in $(<list.txt); do
  cat $a >> onebigfile.avi
done
IFS=$' :\t\n'


rioguia 10-05-2006 07:05 PM

wow! execellent replies.
 
Thanks for the quick replies. I have been working with both suggestions since you posted them.

regarding macemoneta's transcode suggestion, this looks like an excellent tool. It fires up and pulls together the individual movies like a charm. The video is great but I can't make the audio work when the avi is played on a window's box even thought the individual constitutent movie clips do play (I am trying to make movies of my kids that the grand parents can just pop in their PC's and play). I suspect that with more work I will figure this tool out and use it alot. It seems really cool.

Regarding the onsolebox's script, it just fires up and works like a charm. I am still working on the output but think that this one will work for my current purposes until I can make the transcode work. In the meantime, this script has taught me a lot about the magic of bash scripts.

Thanks to both for sharing your knowlege. I love to learn which is why I guess I like linux.

chrism01 10-05-2006 09:14 PM

If you create the big file in a diff directory, you can do it in 1 step:

cat /src_dir/*.avi >> /tgt_dir/big.avi

of course that won't do the fancy sync stuff that avi merge will...

timmeke 10-06-2006 02:38 AM

Just a hint:
Tweak the list of avi files, for instance to get the movies to play in the right order (ie chronological order):

1. ls *.avi => list of avi files
2. edit the list to put the movies in the right order
3. run konsolebox's script on that list


All times are GMT -5. The time now is 10:21 AM.