LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 10-01-2006, 09:12 PM   #1
rioguia
Member
 
Registered: Jun 2002
Posts: 411

Rep: Reputation: 30
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

Last edited by rioguia; 10-01-2006 at 09:13 PM.
 
Old 10-01-2006, 09:24 PM   #2
macemoneta
Senior Member
 
Registered: Jan 2005
Location: Manalapan, NJ
Distribution: Fedora x86 and x86_64, Debian PPC and ARM, Android
Posts: 4,593
Blog Entries: 2

Rep: Reputation: 326Reputation: 326Reputation: 326Reputation: 326
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
 
Old 10-01-2006, 09:44 PM   #3
konsolebox
Senior Member
 
Registered: Oct 2005
Distribution: Gentoo, Slackware, LFS
Posts: 2,245
Blog Entries: 15

Rep: Reputation: 233Reputation: 233Reputation: 233
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'
 
Old 10-05-2006, 07:05 PM   #4
rioguia
Member
 
Registered: Jun 2002
Posts: 411

Original Poster
Rep: Reputation: 30
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.
 
Old 10-05-2006, 09:14 PM   #5
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5, Centos 5.10
Posts: 16,261

Rep: Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028
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...
 
Old 10-06-2006, 02:38 AM   #6
timmeke
Senior Member
 
Registered: Nov 2005
Location: Belgium
Distribution: Red Hat, Fedora
Posts: 1,515

Rep: Reputation: 61
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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help Strip / Remove attachments (Replace with TXT file if Possible) Vince0000 Linux - General 2 09-17-2010 06:46 PM
How do I replace text with perl with a list fo files? nadavvin Programming 7 09-14-2006 07:12 PM
for command not acknologing quotations of a list generated by `ls -Q` or `cat listQ` symo0009 Programming 3 12-26-2005 03:52 PM
Limited Disk Space, Strip executables? pentalive Linux - General 20 06-08-2005 01:55 PM
Bash - Strip Spaces from string then cat cmfarley19 Programming 8 07-25-2004 12:01 PM


All times are GMT -5. The time now is 04:08 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration