SIMPLE BASH Programming.

Posted by atif089 on Stack Overflow See other posts from Stack Overflow or by atif089
Published on 2010-06-16T09:04:17Z Indexed on 2010/06/16 9:12 UTC
Read the original article Hit count: 301

Filed under:
|
|

I am a newbie to BASH so please dont mind my stupid questions because I am not able to get any good sources to learn that.

I want to create a script to display filename and its size. This is what the code is like

filename=$1
if [ -f $filename ]; then
    filesize=`du -b $1`
    echo "The name of file is $1"
    echo "Its size is $filesize"
else
    echo "The file specified doesnot exists"
fi

The output is like this

$ ./filesize.sh aa
The name of file is aa
Its size is 88  aa

But in the last line I dont want to show the name of the file. How do I do that ? I want to do the same thing using wc as well.

© Stack Overflow or respective owner

Related posts about bash

Related posts about unix