The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #5 (permalink)  
Old 01-29-2008
dennis.jacob dennis.jacob is offline Forum Advisor  
dj - the student
  
 

Join Date: Feb 2007
Location: Singapore/Bangalore/Cochin
Posts: 597
Quote:
Originally Posted by smr_rashmy View Post
Could you please explain me both when you find time?

hey its not working ya.

$ dt=`date -u +%d-%m-%y`
$
$ echo $dt
29-01-08
$
$ cat tst.txt
Date 12-01-08
$
$ awk -v dat=$dt -v '{if( $1 ~ /Date/) print $1" "dat;}' tst.txt
Usage: awk [-F fs][-v Assignment][-f Progfile|Program][Assignment|File] ...
$
$ sed -e 's/Date\(.*\)/Date '$dt'/' tst.txt
Date 29-01-08
$ cat tst.txt
Date 12-01-08
$

what is wrong with my command?

Why you have used -v there? Also, if you want these changes to written on to a file, you have to use "> new_filename" at the end...

ie, sed -e 's/Date\(.*\)/Date '$dt'/' tst.txt > temp_new_file