- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Pulling and formatting dates of a file (ls)
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
07-21-2005 06:39 AM
07-21-2005 06:39 AM
Pulling and formatting dates of a file (ls)
something that will let me change the format to MM/DD/YYYY (no timestamp needed for my purpose).
I have awk yanking the date out of the ls, but cannot seem to reformat in a nice way without doing lookup conversions.. I was hoping for something more elegant than that.
TIA!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2005 07:21 AM
07-21-2005 07:21 AM
Re: Pulling and formatting dates of a file (ls)
ll $1 |awk '{print $6,$7,$8}' |read MN DY YR
case $MN in
Jan) MN="01";;
Feb) MN="02";;
Mar) MN="03";;
Apr) MN="04";;
May) MN="05";;
Jun) MN="06";;
Jul) MN="07";;
Aug) MN="08";;
Sep) MN="09";;
Oct) MN="10";;
Nov) MN="11";;
Dec) MN-"12";;
esac
[ $DY -lt 10 ] && DY="0$DY"
[ -n "`echo $YR |grep ':'`" ] && YR=`date '+%Y'`
[ $MN -gt `date '+%M'` ] && YR=`eval $YR - 1`
print "$MN/$DY/$YR"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2005 07:21 AM
07-21-2005 07:21 AM
Re: Pulling and formatting dates of a file (ls)
Use awk, separate the MM(text) DD and YYY from ls. Then take the MM(text) and use a conversion table, case statement, or other means to convert the text month to a number.
i.e
case MM in
Jan) MONTH=1
Feb) Month=2
...;;
esac
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2005 07:24 AM
07-21-2005 07:24 AM
Re: Pulling and formatting dates of a file (ls)
ll $1 |awk '{print $6,$7,$8}' |read MN DY YR
case $MN in
Jan) MN="01";;
Feb) MN="02";;
Mar) MN="03";;
Apr) MN="04";;
May) MN="05";;
Jun) MN="06";;
Jul) MN="07";;
Aug) MN="08";;
Sep) MN="09";;
Oct) MN="10";;
Nov) MN="11";;
Dec) MN-"12";;
esac
[ $DY -lt 10 ] && DY="0$DY"
[ -n "`echo $YR |grep ':'`" ] && YR=`date '+%Y'`
[ $MN -gt `date '+%M'` ] && YR=`eval $YR - 1`
print "$MN/$DY/$YR"
"fordate.sh" 25 lines, 439 characters
[ $DY -lt 10 ] && DY="0$DY"
if [ -n "`echo $YR |grep ':'`" ] ;then
YR=`date '+%Y'`
[ $MN -gt `date '+%M'` ] && YR=`eval $YR - 1`
fi
print "$MN/$DY/$YR"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2005 07:25 AM
07-21-2005 07:25 AM
Re: Pulling and formatting dates of a file (ls)
http://hpux.cs.utah.edu/hppd/hpux/Users/els-1.48a/
HTH
-- Rod Hills