Register
It is currently Fri Dec 26, 2014 5:44 am

echo-ing to multiple files at once


All times are UTC - 6 hours


Post new topic Reply to topic  [ 8 posts ] 
Author Message
 PostPosted: Tue May 03, 2011 6:02 pm   

Joined: Fri Apr 29, 2011 2:52 pm
Posts: 8
okay so say you're in directory /a/b/c/

and folder c has folders 1, 2, 3, 4, 5, 6, and....

and there is a file called "file" in folders (1-6)

but now that we know that file is in all 6 of those folders lets say that in folders 1,4, and 5 the value of the file "file" was 100 and in all the other folders the value for that file is 0.

if i only want to change the value of the files that have their default value as 100 to lets say.....200

but i want to do it all at once besides just running:

echo 200 > /a/b/c/1/file
echo 200 > /a/b/c/4/file
echo 200 > /a/b/c/5/file

and letting the others stay 0.


...any help is appreciated thanks a lot


Top
 Profile  
 PostPosted: Tue May 03, 2011 7:09 pm   

Joined: Mon Mar 02, 2009 3:03 am
Posts: 579
Hi,


do you have the gift of ubiquity?
bash either.


Top
 Profile  
 PostPosted: Wed May 04, 2011 9:30 am   
User avatar

Joined: Tue Apr 27, 2010 2:28 pm
Posts: 172
Location: Czech Republic
Something like this?
Code:
sed -i~ 's/^100$/200/' /a/b/c/[123456]/file


Top
 Profile  
 PostPosted: Wed May 04, 2011 7:49 pm   

Joined: Fri Apr 29, 2011 2:52 pm
Posts: 8
choroba wrote:
Something like this?
Code:
sed -i~ 's/^100$/200/' /a/b/c/[123456]/file

could you explain exactly what that does? thank you


Top
 Profile  
 PostPosted: Thu May 05, 2011 8:28 am   
User avatar

Joined: Tue Apr 27, 2010 2:28 pm
Posts: 172
Location: Czech Republic
kifno wrote:
choroba wrote:
Something like this?
Code:
sed -i~ 's/^100$/200/' /a/b/c/[123456]/file

could you explain exactly what that does? thank you

It changes "100" standing solely on a line to "200" in all the "file"s in the given directories. Did I get your specification right?


Top
 Profile  
 PostPosted: Thu May 05, 2011 9:58 am   

Joined: Fri Apr 29, 2011 2:52 pm
Posts: 8
choroba wrote:
kifno wrote:
choroba wrote:
Something like this?
Code:
sed -i~ 's/^100$/200/' /a/b/c/[123456]/file

could you explain exactly what that does? thank you

It changes "100" standing solely on a line to "200" in all the "file"s in the given directories. Did I get your specification right?

say if you don't know all the folders inside the directory /a/b/c/

would it be
Code:
sed -i~ 's/^100$/200/' /a/b/c/[ls -d]/file
?


Top
 Profile  
 PostPosted: Thu May 05, 2011 3:14 pm   
User avatar

Joined: Tue Apr 27, 2010 2:28 pm
Posts: 172
Location: Czech Republic
kifno wrote:
say if you don't know all the folders inside the directory /a/b/c/

would it be
Code:
sed -i~ 's/^100$/200/' /a/b/c/[ls -d]/file
?

If you want everything, use *.


Top
 Profile  
 PostPosted: Fri May 06, 2011 5:32 am   

Joined: Fri Apr 29, 2011 2:52 pm
Posts: 8
choroba wrote:
kifno wrote:
say if you don't know all the folders inside the directory /a/b/c/

would it be
Code:
sed -i~ 's/^100$/200/' /a/b/c/[ls -d]/file
?

If you want everything, use *.


thanks i'll see if that works for my purpose :D


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Google [Bot] and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP