- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Extract date also
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2006 02:46 AM
02-15-2006 02:46 AM
Thanks again for all the help with the du command. I'm now trying to find a way to pull out the date attached to each file. Can this be tacked on to this 'du -akx | sort -rn | sort -k 2,2 | more > file.lst'?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2006 02:56 AM
02-15-2006 02:56 AM
Re: Extract date also
The du command does nothing with dates - you could do something like this, however:
for FILE in `cat file.lst`
do
ll $FILE | awk '{ print $6 " " $7 " " $8 " " }'
done
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2006 02:56 AM
02-15-2006 02:56 AM
Re: Extract date also
| awk '{print $3}'
change the $3 to include the date fields.
Or process to a file and then cat the file through awk.
There are a few good ways to do this.
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2006 02:58 AM
02-15-2006 02:58 AM
Re: Extract date also
can you please clarify:
du does not include the date at any stage.
Or
Do you mean include the date in the filename:
du -akx | sort -rn | sort -k 2,2 | more > `date +"%C%Y%m%d"`.lis
See man date for format
Or
If you want to see the date for each entry in your file you would have to use ls -ld
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2006 03:04 AM
02-15-2006 03:04 AM
Re: Extract date also
143600 ./scans/MCI. I would like to get this along with the date.
Thanks,
Conrad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2006 03:21 AM
02-15-2006 03:21 AM
Re: Extract date also
Well, you could do something crude like this:
# du -axk | sort -k1nr | perl -lanF -e ';print "$F[0]\t$F[1] : ",scalar localtime ((stat($F[1]))[9])'
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2006 04:09 AM
02-15-2006 04:09 AM
Re: Extract date also
It works, sort of. I can't run it as root but I can live with that I guess. I also modified it back to sort the way it was before I just wanted to include the date tag.
du -akx | sort -rn | sort -k 2,2 | perl -lanF -e ';print "$F[0]\t$F[1] : ",scalar localtime ((stat($F[1]))[9])' > outfile.lst
It seems that when I try and run it as root, root can't find perl. I get 'sh: perl: not found.'
Thanks for all the help,
Conrad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2006 04:12 AM
02-15-2006 04:12 AM
Re: Extract date also
probably means the perl executable in not in your PATH.
Once you found perl, just add it to your path:
export PATH=$PATH:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2006 04:50 AM
02-15-2006 04:50 AM
Re: Extract date also
It runs now if I switch to su - but it still does not work if I switch to su.
Cheers,
Conrad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2006 04:54 AM
02-15-2006 04:54 AM
SolutionThe difference between 'su' and 'su -' allowing you to see perl points to a PATH issue.
If you execute 'su -' you are sourcing the profile of the user to which you are switching, otherwise you are not.
As Gordon said, you need to add perl to your path. It maybe that perl is installed in '/opt/perl/bin/perl' but this isn't in your path. An easy choice is to create a symbolic link :
# ln -s /opt/perl/bin/perl /usr/bin/perl
Now, since '/usr/bin' will be in your path, so will 'perl'.
Regards!
...JRF...