I want to input a string through command line to bash script and output to that string to a text file with current system time as follows.
outputLog.txt
name1 = Tue Jan 20 14:00 19 IST 2012
name2 =Tue Jan 20 14:05 19 IST 2012
name3 = Tue Jan 20 14:20 19 IST 2012
name4 =Tue Jan 20 14:45 19 IST 2012
I use the following bash script to obtain the output above
#!/bin/bash
echo "$1 = $(date)" >>/root/Desktop/scripts/outputLog.txt
In command line
[root@localhost desktop]# ./myscript.sh name1
Is there any possible way to search the name entered through command line is already found in generated output text file?if found update the current system time of that name string
in command line we enter
[root@localhost desktop]# ./myscript.sh name1
name1 is already occupied in the outputLog.txt. I want to output the the text file as
name1 = Tue Feb 21 14:00 19 IST 2012(todays current system time)
name2 =Tue Jan 21 14:05 19 IST 2012
name3 = Tue Jan 21 14:20 19 IST 2012
name4 =Tue Jan 21 14:45 19 IST 2012
How can i update that name string with current system time.
might work for you. Note that it fails, if your
nameNcan contain any/.