• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: (resend) - $ dir=/Some/Path/To/Server ; y=`date +%Y`; ls -lR $dir | sed -e "s/[0-9]*:[0-9]*/ `echo ${y}`/g"
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: (resend) - $ dir=/Some/Path/To/Server ; y=`date +%Y`; ls -lR $dir | sed -e "s/[0-9]*:[0-9]*/ `echo ${y}`/g"


  • Subject: Re: (resend) - $ dir=/Some/Path/To/Server ; y=`date +%Y`; ls -lR $dir | sed -e "s/[0-9]*:[0-9]*/ `echo ${y}`/g"
  • From: Bill Hernandez <email@hidden>
  • Date: Fri, 26 Mar 2010 22:14:19 -0500


On Mar 26, 2010, at 4:33 PM, Alex Zavatone wrote:

One problem is that sometimes, the date is returned as "Sep  9  2009"  And other times, it is returned as "Sep 25 16:42".  does anyone know if there is a Unix option to limit the number of output columns for ls -tl or ls -to??


Zav,

------------------------------------------------------
NOTES : Sample code for [ ls ] command...
------------------------------------------------------
# DISPLAY HIDDEN FILES SHORT
# .bash_history
alias lhs='ls -a | grep "^\.[a-zA-Z]"'
ls -a | grep "^\.[a-zA-Z]"

# DISPLAY HIDDEN FILES LONG
# -rw-------     1 bhernand  bhernand   5156 May 12 19:46 .bash_history
alias lhl='ls -la | grep " \.[a-zA-Z]"'
ls -la | grep " \.[a-zA-Z]"
# LIST CURRENT DIRECTORY AND SORT BY THE 9TH COLUMN (FILENAME)
ls -lF | sort -k 9
# LIST CURRENT DIRECTORY AND REVERSE SORT BY THE 9TH COLUMN (FILENAME)
ls -lF | sort -r -k 9

# LIST CURRENT DIRECTORY RECURSIVELY AND SORT BY THE 9TH COLUMN (FILENAME)
cd ~/unix_scripts/
ls -RlF | sort -k 9
# LIST RECURSIVELY THE SPECIFIED DIRECTORY AND SORT BY THE 9TH COLUMN (FILENAME)
ls -RlF ~/unix_scripts/ | sort -k 9


# This next line semi solves the DATE/TIME problem. 
# You either have to check against month/day, or just accept that the year might be off by one.
dir=/Some/Path/To/Server ; y=`date +%Y`; ls -lR $dir | sed -e "s/[0-9]*:[0-9]*/ `echo ${y}`/g"
# Try this, it will give you the {permissions, owner, group, name} sorted by permissions
ls -ls /Users/Shared/debug_do_not_throw | awk '{print $2" "$4" "$5" "$10}' | sort -k 1
# Try this, it will give you the fiels only {permissions, owner, group, name} sorted by {name, permissions}
dir=/Users/Shared; ls -lR $dir | grep "^[-]" | awk '{print $1" "$3" "$4" "$9}'| sort -fk 9 | sort -fk 1
# Try this, it will give you the directories only {permissions, owner, group, name} sorted by {name, permissions}
dir=/Users/Shared; ls -lR $dir | grep "^[d]" | awk '{print $1" "$3" "$4" "$9}'| sort -fk 9 | sort -fk 1
# THESE ARE REALLY HANDY:
# The two commands below make it very easy to scan the permissions for a whole directory hierarchy, 
# in order to see if anything looks out of place. The funny thing is that nothing aligns correctly. 
# The display is not uniform at all within the last three or four fields.
# LIST ALL DIRECTORIES :
# 1st level sort on [permissions and size] and 2nd level sort on [dirname]
$ dir=/Some/Path/To/WebServer; ls -lR $dir | grep "^[d]" | sort -fk 9 | sort -fk 1
# LIST ALL FILES :
# 1st level sort on [permissions and size] and 2nd level sort on [filename]
$ dir=/Some/Path/To/WebServer; ls -lR $dir | grep "^[-]" | sort -fk 9 | sort -fk 1

Best Regards,

Bill Hernandez
Plano, Texas

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

References: 
 >(resend) (From: Alex Zavatone <email@hidden>)

  • Prev by Date: Re: (resend)
  • Next by Date: Re: Filemaker Find Question - Help please...
  • Previous by thread: Re: (resend)
  • Next by thread: Filemaker Find Question - Help please...
  • Index(es):
    • Date
    • Thread