substituting with two blanks in sed
|
Original Message
|
Name: Hugo
Date: December 9, 2005 at 10:10:19 Pacific
Subject: substituting with two blanks in sedOS: Solaris 9CPU/Ram: 4GB |
Comment: Hi all, I am trying to list files with todays date only. I can not get sed to add the extra blank when finding single digit dates 1-9. i.e, Solaris list files with dates: "Dec 9" (no quotes) my initial date commands return "Dec 09", hence I am using sed, but my script keep returning Dec 9 I need two blank spaces before 9 Any ideas why? how to fix it? thanks #!/usr/bin/ksh TIME=`/usr/bin/date '+%h %d' | sed 's/ 0/ /'` ls -l /mydir | grep "$TIME"
Report Offensive Message For Removal
|
|
Response Number 1
|
Name: nails
Date: December 9, 2005 at 14:39:00 Pacific
Subject: substituting with two blanks in sed |
Reply: (edit)Maybe I'm missing something, but just put an extra space in: TIME=`/usr/bin/date '+%h %d' | sed 's/ 0/ /'` to # there needs to be two spaces # between the last two the last / and / TIME=`/usr/bin/date '+%h %d' | sed 's/ 0/ /'` Also, I think you can save yourself the trouble of using the grep: ls -l /mydir | grep "$TIME" Change it to: ls -l mydir/*"$TIME"
Report Offensive Follow Up For Removal
|
|
Response Number 2
|
Name: ghostdog
Date: December 14, 2005 at 07:14:33 Pacific
Subject: substituting with two blanks in sed |
Reply: (edit)if you just want to find files with todays date only, can also use the find command find <path> -type f -mtime -1 -ls
Report Offensive Follow Up For Removal
|
Use following form to reply to current message: