Hello,
I have a script that should store file size in a variable $filesize.
I don't know what is the best way to do it.
I tried
ls -lt myfile.txt | sed something >$filesize
but I don't know how to use sed to get filesize. I know that the owner of the file is root and then we have some spaces, then the file size value then some spaces.
Maybe there is also other way to do it
filesize=`ls -l myfile.txt | awk '{ print $5 }'`
thanks
ls is in a ssh command
$filesize = `ssh root@$myip (ls -lt myfile.txt | awk '{ print $5 }')`
to know filesize on a remote computer
will it work knowing that I got public key authorized for $myip computer.
If you have stat (man 1 stat) installed this is a more concise way to get your filesize.
Assigning a shell variable in such a way will surely not work... Are you using Perl?
For sh/bash this will work:
filesize=`ssh root@$myip ls -l myfile.txt | awk '{ print $5 }'`
Nop, I don't have perl
I have an error not a valid identifier but I have the good result in it.
set $bibi=`ls -lk myfile | awk '{print $5}'`
bash : error `21 not a valid identifier,
21 is the size of the file
if you want to assign the result to bibi, then
bibi=`ls -l .... .`