Jump to content

Featured Replies

Posted

Hello,

I heva a problem creating a script that read specifc value from all the files of an entire folder

 

I have a number of email files into a directory and i need to extrect from each file 2 specific values.

After that i have to put them into a new file that looks like that:

--------------

To: value1

 

value2

--------------

 

This is what i want to do, but i don't know how to create the script:

 

ls -l | awk '{print $9 }' >tmpfile - i am putting the name of the files into a temp file

date=`date +"%T"` - used for the name of a file

var1=`cat tmpfile | grep "To: 0" | awk '{print $2 }' | cut -b -10 ` - the first specific value from file(phone number)

var2=cat file | grep Subject | awk '{print $2$3$4$5$6$7$8$9$10 }' - the second specific value from file(subject)

echo "To: 4"$var1"" > sms-$date - put the first value in a new file on the first row

echo ""$var2"" >>sms-$date put the second value in the same file on the second row

.......

and do the same for every file in the directory

 

I tried using while and for functions but i couldn't finalize the script

 

Thank You

 

Continue reading...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...