Create a script to display file name, Inode, and size of any file. Has to be a script
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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?
#!/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
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
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.