SlackwareThis Forum is for the discussion of Slackware Linux.
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.
Anyone know how to output a file list "exactly" like the ones included with Slackware from a shell? Or even how Patrick does it? I've been playing with this for hours and best I can come up with is something like this:
This is closer, but still not exact. Just missing the time because I haven't figured out how to extract just the time and not the nano second that trails with --full-time option yet. And I changed the size format.
Posting this here in hopes that someone else may find it useful, or better yet improve upon it and repost.
Code:
#!/bin/sh
#
# USE AT YOUR OWN RISK!!!!!
#
# buildlist.sh
#
# Builds a recursive directory list file like the FILELIST.TXT that ships
# with Slackware Linux.
#
# Usage:
# Run ./buildlist.sh path/to/directory
# or ./buildlist.sh /path/to/directory /path/to/listfile
# listfile being the name of the new file that will be created, of course.
LISTFILE=FILELIST.TXT # Default listfile
# Uncomment one or the other, but not both
#SIZEOP=h # Use human readable sizes vs bytes (ie MB/KB)
SIZEOP="" # Use bytes for sizes
if test "$1" == ""; then
echo "Usage: $0 directory listfile(optional)"
exit
else
if test ! -d $1; then
echo "Error: $1 - No such directory..."
exit
fi;
fi;
if test "$2" != ""; then
LISTFILE=$2
fi;
echo "Building \"${LISTFILE}\" from \"$1\""
date > ${LISTFILE}
cat <<- EOF >> ${LISTFILE}
Directory listing of $1
EOF
find ${1} -exec ls -dl${SIZEOP} --full-time {} \; \
| awk '{ printf("%10s %2s %4s %4s %8s %10s %-5.5s %s\n",$1,$2,$3,$4,$5,$6,$7,$9) }' > templist.txt
sort +7d templist.txt >> ${LISTFILE}
rm templist.txt
echo "Done!"
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.