Register
It is currently Wed Oct 01, 2014 8:21 pm

put $variable inside a file.txt


All times are UTC - 6 hours


Post new topic Reply to topic  [ 3 posts ] 
Author Message
 PostPosted: Tue Dec 10, 2013 6:19 am   

Joined: Mon Nov 25, 2013 10:04 am
Posts: 9
Hi guys, i have a little bashscript:

Code:
mail_body_file="mailbody.txt"

for fullname in *.zip; do
    filename="${fullname%.*}"
mutt -a $fullname -s "Attachment $fullname" xxx@xxx.com < $mail_body_file


I have two question;
-is possible put the $filename inside mailbody.txt ?
-is possible put it in a specific line of mailbody.txt ?

Thank You


Top
 Profile  
 PostPosted: Tue Dec 10, 2013 8:05 pm   
User avatar

Joined: Wed Jun 08, 2011 8:27 am
Posts: 189
Location: outer Shpongolia
Do you mean doing something else than simply appending each filename to the file?


If specific line refers to a line number:

The following would insert the filename on, e.g., the second line:
Code:
perl -spi.bak -le '$. == $n && print $f' -- -n=2 -f="$filename" "$mail_body_file"

----

Don't forget to double-quote variable expansions.
Note that you don't need to do it on assignments' RHS since it doesn't undergo word splitting.


(done is missing.)


Top
 Profile  
 PostPosted: Fri Dec 13, 2013 7:33 am   

Joined: Mon Nov 25, 2013 10:04 am
Posts: 9
jsz wrote:
Do you mean doing something else than simply appending each filename to the file?


If specific line refers to a line number:

The following would insert the filename on, e.g., the second line:
Code:
perl -spi.bak -le '$. == $n && print $f' -- -n=2 -f="$filename" "$mail_body_file"

----

Don't forget to double-quote variable expansions.
Note that you don't need to do it on assignments' RHS since it doesn't undergo word splitting.


(done is missing.)


Thank You Jsz


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

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 7 guests


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