![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Appending date to filename | aemunathan | Shell Programming and Scripting | 5 | 05-12-2008 08:21 AM |
| Date Not appending in log file | vrjalli | Shell Programming and Scripting | 4 | 01-24-2008 05:33 AM |
| appending with AWK | harris2107 | Shell Programming and Scripting | 5 | 09-20-2007 04:27 AM |
| appending and sed | scotty_123 | Shell Programming and Scripting | 1 | 04-26-2007 08:13 AM |
| appending | codewarrior7 | Shell Programming and Scripting | 5 | 02-09-2005 10:26 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Appending date
hi All, Searched forum but couldn't find a solution to this problem: How can I append a file with date in the ninth line? ie I want to insert a line with the current date and time in the ninth line. I tried this: Code:
date=`date`
awk 'NR==9 {printf "'$date' \n"} {print $0}' abc.log
below the error I am getting Quote:
|
|
||||
|
If your awk supports the -v option, you can specify multiple -v options to set multiple variables. But the original script was basically fine; you just need to quote the string properly. Add double quotes around $date and it should work.
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|