Create a script to display file name, Inode, and size of any file. Has to be a script
This is what I have so far:
FILE="$1" if [ $# -eq 0 ]; then echo "$(The filename is: $0) - file-name" exit 1 fi set temp = `ls -l $fileName` set size = $temp[4] if (! -d $file) set temp = `ls-l $file` bytes = $bytes + $temp[4] fi echo "Total size = $bytes bytes." textArray[0]="" # hold text c=0 # counter # read whole file in loop while read line do textArray[c]=$line # store line c=$(expr $c + 1) # increase counter by 1 done < $FILE # get length of array len=$(expr $c - 1 ) # use for loop to reverse the array for (( i=$len; i>=0; i-- )); do echo ${textArray[$i]} done I created this in VI. I want to be able to display the filename, size, and Inode. Can anyone direct me? |
"man stat" would be a good start.
|
How about this:
Code:
#!/bin/bash |
or
Code:
#!/bin/sh |
It is that simple? I did all that and it can be compiled into one line?:scratch:
|
'man ls' will explain the options, but yes, it's just a one line script.
|
I ran this code, but didn't get any file information:
#!/bin/sh if [ -f "$1" ]; then file=`readlink -f "$1"` attrib=`stat -c "inode:%i size:%s" "${file}"` echo "file:${file:=ERROR} ${attrib:=ERROR}" else echo "This is soo bad, its a crime."; fi exit 0 |
You have to supply a /path/to/file as argument:
Code:
sh /tmp/script.sh /tmp/adore.o |
All times are GMT -5. The time now is 05:40 PM. |