hi all,
there is any command or anything we can use to read the file name and size. thanks
ls -l
If that's not the command you were looking for, then post a better question.
okkk....sorry i ask u bit wrong question....
here is what i want to do..
i wanna read only file name and size from ls -l out put (-rwxr-xr-x 1 root root 220 Jan 7 09:15 filmon) and also i wanna store them in variables. Thanks.
set -f
set -- $( ls -l filmon )
size=$5
filename=$9
fname=`stat -c '%n' file`
fsize=`stat -c '%s' file`
for file name use this command
export file_name=`ls -l | awk '{print $9}'`
echo $file_name to display
for size file_size=`ls -l | awk '{print $5}'`
echo $file_size to display
The stat command is not standard, and neither is its syntax on those systems that do have it:
$ fname=`stat -c '%n' file`
stat: illegal option -- c
usage: stat [-FlLnqrsx] [-f format] [-t timefmt] [file ...]
The -c option works with the GNU version of stat, but it is only necessary to call it once:
eval "$( stat -c 'fname="%n" fsize="%s"' "$FILE"' )
The *BSD syntax is:
eval "$( stat -f 'fname="%N" fsize="%z"' "$FILE"' )