LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-09-2009, 04:14 PM   #1
shoemoodoshaloo
LQ Newbie
 
Registered: Jun 2009
Posts: 18

Rep: Reputation: 0
File manipulation question


Hey everyone,

I have a script with a nested loop which upon each iteration outputs a file, call it output.bed

Before the loop ends, I would like to dump the contents of output.bed into another file, call it temp.bed, so that after each iteration, temp.bed fills up with an additional line of data. The data that is being output is simply a number. So, for example my temp.bed file should be something like:
1
2
3
4
5

Do you guys know a good command that will take the contents of one file and just dump it into another? I am trying things like:

echo $ROOTDIR/$OUTDIR/$COVERAGEFILE >> $ROOTDIR/$OUTDIR/NUMTAGS

but that is not dumping the contents of the file, rather it is dumping the directory:

./mm8-small-DATA/mm8-small-N.bed
./mm8-small-DATA/mm8-small-N.bed
./mm8-small-DATA/mm8-small-N.bed
./mm8-small-DATA/mm8-small-N.bed
./mm8-small-DATA/mm8-small-N.bed

instead of

1
2
3
4
5

Any help would be appreciated.
 
Old 06-09-2009, 04:17 PM   #2
ramram29
Member
 
Registered: Jul 2003
Location: Miami, Florida, USA
Distribution: Debian
Posts: 848
Blog Entries: 1

Rep: Reputation: 47
You have to use cat instead of echo.
 
Old 06-09-2009, 04:33 PM   #3
shoemoodoshaloo
LQ Newbie
 
Registered: Jun 2009
Posts: 18

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by ramram29 View Post
You have to use cat instead of echo.
When I do that I get:

12345

If I understand correctly, I need to put a /n in there. I also need a -e correct, however, the computer is barking at me. I'm trying this for example:

cat -e $ROOTDIR/$OUTDIR/$COVERAGEFILE \n >> $ROOTDIR/$OUTDIR/NUMTAGS


How can I add a new line character at the end of the cat command?
 
Old 06-09-2009, 05:57 PM   #4
ramram29
Member
 
Registered: Jul 2003
Location: Miami, Florida, USA
Distribution: Debian
Posts: 848
Blog Entries: 1

Rep: Reputation: 47
You need to run a for loop like this:

for i in $(cat $ROOTDIR/$OUTDIR/$COVERAGEFILE); do echo $i >> $ROOTDIR/$OUTDIR/NUMTAGS; done
 
  


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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
file name manipulation chocolatetoothpaste Linux - Software 19 04-03-2006 11:18 AM
Mass file manipulation Drack Linux - General 5 02-27-2006 07:40 AM
file manipulation with c C.Aymen Programming 2 09-01-2005 01:48 PM
C File Manipulation in Linux drigz Programming 5 10-01-2004 08:28 AM
Yep, another PHP question (File manipulation) jacksmash Programming 6 11-22-2003 02:07 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:06 PM.

Main Menu
Advertisement
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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration