[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Extracting fields (was bash: get file modification time query)



On Wed  9 Jul 2003 19:53:05 +0000(+0100), David selby wrote:
> Is there a neater way to get a modification date for a file without ls 
> -l & sed ? I have a bash script that needs to get the info. Because the 
> file size varies I cannot use cut, it may cut the wrong bit.

Dave,

Firstly I don't mean to detract from the 'stat' suggestion which looks neat
for the particular problem you described (in fact I've just installed stat).

In general, when you want to extract fields rather than columns, you can
do something like

ls -l $filename | awk '{print $6, $7, $8}'
or
set -- `ls -l $filename`; echo $6 $7 $8

Note the latter replaces your positional parameters.

-- 
Cheers,
Clive



Reply to: