![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Automatic name file with increase | steiner | Shell Programming and Scripting | 6 | 05-29-2007 04:14 AM |
| Increase size of /tmp swap File | cmackin | SUN Solaris | 2 | 06-01-2006 03:14 PM |
| HELP! The '/var/adm/message' file increase every few seconds??? | cloudsmell | UNIX for Dummies Questions & Answers | 3 | 09-17-2002 03:04 PM |
| HELP! The '/var/adm/message' file increase every few seconds??? | cloudsmell | Filesystems, Disks and Memory | 1 | 09-16-2002 10:31 PM |
| Increase width of Spool file | handynas | UNIX for Dummies Questions & Answers | 2 | 11-20-2001 09:24 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
File increase
Sorry im really new here this is my second post today!
My question is, im trying to write a script and i want to output to a text file but i want each text file to be different so for instance log.txt, log1.txt, log2.txt ect how would i do that? |
|
||||
|
Hi,
This is the code im running, now where it says log.txt i want to put a line of code in to create a new file each time and adjust the other log entries #!/bin/sh echo STARTING...... date echo echo echo echo echo echo echo echo echo echo echo echo echo echo echo w >>log.txt echo echo echo echo echo "UNZIP FILES" unzip \*.zip >>log.txt echo echo echo echo date >>log.txt whoami >>log.txt quota >>log.txt echo "the task was performed correctly" >>log.txt echo echo echo echo echo echo echo echo echo echo echo echo echo echo echo echo FINISHED... |
|
||||
|
i think instead of hardcoding the file name u can parameterize the same by writing a code to take the file name from standard i/p each time u run the script.
here it goes. #!/bin/sh echo " enter the file name " read name echo STARTING...... date echo echo echo echo echo echo echo echo echo echo echo echo echo echo echo w >> $name echo echo echo echo echo "UNZIP FILES" unzip \*.zip >>$name echo echo echo echo date >>$name whoami >>$name quota >>$name echo "the task was performed correctly" >>$name echo echo echo echo echo echo echo echo echo echo echo echo echo echo echo echo FINISHED... i think it works...please reply if it works......as i am also new to scripting rgds, jam |
|
|||||
|
Now that I see your last post, I guess you didn't understand one of my answers.
I'm going to modify your code to see if you understand it now ![]() Code:
#!/bin/sh
TIMESTAMP=$(date +"%d%m%Y%H%M%S")
name=/path/to/logfile/file_${TIMESTAMP}.log
echo STARTING......
date
echo
echo
echo
echo
echo
echo
echo
echo
echo
echo
echo
echo
echo
echo
echo
w >> $name
echo
echo
echo
echo
echo
"UNZIP FILES"
unzip \*.zip >>$name
echo
echo
echo
echo
date >>$name
whoami >>$name
quota >>$name
echo "the task was performed correctly" >>$name
echo
echo
echo
echo
echo
echo
echo
echo
echo
echo
echo
echo
echo
echo
echo
echo FINISHED...
Regards. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|