![]() |
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 |
| "find command" to find the files in the current directories but not in the "subdir" | swamymns | Shell Programming and Scripting | 9 | 07-22-2008 11:23 AM |
| Command to find out "count" of running process ? | MITESH KOTHARI | Shell Programming and Scripting | 4 | 04-01-2008 03:27 AM |
| grep for "exact word" | bullz26 | Shell Programming and Scripting | 7 | 03-14-2008 05:00 AM |
| grep to find content in between curly braces, "{" and "}," | keshav_rk | Shell Programming and Scripting | 4 | 08-09-2007 10:14 PM |
| How to combine "find" command in for each loop (tcsh) | umen | Shell Programming and Scripting | 3 | 08-22-2005 04:07 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Hi,
I understand that the ls command with "-l" option generates the "last modified time" of specific directory. However, some generated results displayed the "last modified time" with detail about the last modified year, for example: -rwxrwxrwx+ 1 smith dev 10876 May 16 2005 part2 some results, on the other hand, only display the detail about the time but not the year, for example: -rwxrwxrwx+ 1 smith dev 10876 May 16 9:42 part2 I would appreciate if anybody could tell me how to find out the last modified year if I got the latter result, i.e. output with last modified time only. Thank you. |
|
||||
|
hi
it does not work on unix. i dont know if there is any command for this query. As i m new to unix/linux/ here one logic im trying to use.. when we do ls-l in resultant set -- update date/time - we have capital letter like Apr,Mar,Jan if we are able to get that character -- and next max12 chracters. then u can get the required year. like -rwxrwxrwx 1 aaamart 901 176 Mar 29 15:12 casetest.sh -rwxrwxrwx 1 aaamart 901 2 Apr 10 10:03 cronsettings here M- Mar and A- Apr and then if ":" exists then year is current year or the specified year. regards, swapneel |
|
||||
|
hi
try this ls -lg | awk '// { if(length($7)==4) { print $8,$7 } else { print $8, system("date +%Y") } }' it will prints file name and year - if exists otherwise it will print file name and current year. it also returns ls -lg output i dont know how to avoid that might be someone from foroum willhelp us regards, swapneel |
|
||||
|
Code:
#! /usr/bin/ksh
curr=`date +%Y`
ls -l | while read file
do
if [ `echo $file | nawk '{print gsub(/:/," ",$0)}'` -eq 1 ]
then
echo $file $curr | nawk '{print $9"---"$10}'
else
echo $file | nawk '{print $9"---"$8}'
fi
done
exit 0
if its a current file file1---2006 and probably for an old file from 2004 then oldfile1---2004 |
|
|||||
|
See my script in this thread.
|
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Tags |
| linux |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|