bgunn
01-20-2003, 12:21 AM
Hi All
I am trying to write a script that tests the size of a file. I have tried using this line to assign the file size to a variable, but it wont work. It just says
" filesize: line 7: | cut -f 5 -d : command not found "
Here is the script:
----------------------------------
#!/bin/bash
echo
echo -n "Enter file name "
read FILENAME
SIZE='ls -l $FILENAME | tr -s ' ' | cut -f 5 -d ' ''
echo "Size of '$FILENAME' is $SIZE"
exit
------------------------------------
Any suggestions?
Thanks, Ben
I am trying to write a script that tests the size of a file. I have tried using this line to assign the file size to a variable, but it wont work. It just says
" filesize: line 7: | cut -f 5 -d : command not found "
Here is the script:
----------------------------------
#!/bin/bash
echo
echo -n "Enter file name "
read FILENAME
SIZE='ls -l $FILENAME | tr -s ' ' | cut -f 5 -d ' ''
echo "Size of '$FILENAME' is $SIZE"
exit
------------------------------------
Any suggestions?
Thanks, Ben