From: MuthuKumar (kmuthukumar@lycos.co.uk)
Date: Wed Oct 06 2004 - 09:06:56 EDT
>
> not much on scripting and in need of a script to search directory "/abc/xyz"
> for filename "joesfile" and if it is found, store it's file size in a
> variable "filesize".
>
> after struggling with punctuation, i used the following to take care of my
> search need, where joesfile is always in directory /abc/xyz:
>
> filesize=$(ll /abc/xyz/joesfile | awk `{print $5}`)
If a file named /abc/xyz/joesfile there only your file size will be there. Else it is none there.
To make more efficient then,
[[ -f /abc/xyz/joesfile ]] && filesize=$(ls -s /abc/xyz/joesfile | awk `{print $1}`)
It will give the size when the file /abc/xyz/joesfile must be there. Else it will not assign file size there.
Regards
-Muthukumar
--- =============== It is a "Virus Free Mail" =============== Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.772 / Virus Database: 519 - Release Date: 10/1/2004 -- ---> Please post QUESTIONS and SUMMARIES only!! <--- To subscribe/unsubscribe to this list, contact majordomo@dutchworks.nl Name: hpux-admin@dutchworks.nl Owner: owner-hpux-admin@dutchworks.nl Archives: ftp.dutchworks.nl:/pub/digests/hpux-admin (FTP, browse only) http://www.dutchworks.nl/htbin/hpsysadmin (Web, browse & search)
This archive was generated by hypermail 2.1.7 : Sat Apr 12 2008 - 11:02:43 EDT