#!/bin/sh ## ## SCRIPT: F2d_anyfile4Dir_LIST_FILESdirs-all_allLEVS_ls-lApR.sh ## ## PURPOSE: List ALL files in a directory AND in its ## subdirectories at ALL levels below, using 'ls -l'. ## ## METHOD: Puts the output of the 'ls -l' command in a text file. ## ## Shows the text file using a text-file viewer of the user's ## choice. ## ## HOW TO USE: In Nautilus, select any file in the 'navigated to' directory. ## Then right-click and choose this Nautilus script to run. ## ## Created: 2013oct28 Based on script ## F2c_anyfile4Dir_LIST_FILESdirs-all_allLEVS_ls-ApR.sh ## Changed: 2013 ## FOR TESTING: (show statements as they execute) # set -x ################################################# ## Prepare the output file. ## ## If the user has write-permission on the ## current directory, put the file in the pwd. ## Otherwise, put the file in /tmp. ################################################# CURDIR="`pwd`" OUTFILE="${USER}_temp_dirAllFILESrecursiveList_ls-lApR.txt" if test ! -w "$CURDIR" then OUTFILE="/tmp/$OUTFILE" fi if test -f "$OUTFILE" then rm -f "$OUTFILE" fi ##################################### ## Generate a heading for the listing. ##################################### DATETIME=`date '+%Y %b %d %a %T%p'` echo "\ ..................... $DATETIME ............................ List of FILES (and DIRECTORIES) under directory $CURDIR --- ALL levels (recursive). Includes 'hidden' files. ........................................................................... " > "$OUTFILE" ####################################### ## Add the 'ls -l' output to the listing. ####################################### # ls -l -A -p -R --group-directories-first >> "$OUTFILE" ls -l -A -p -R >> "$OUTFILE" ##################################### ## Add a trailer to the listing. ##################################### SCRIPT_BASENAME=`basename $0` SCRIPT_DIRNAME=`dirname $0` echo "\ ........................................................................... This list was generated by script $SCRIPT_BASENAME in directory $SCRIPT_DIRNAME Used command ls -l -A -p -R '-l' requests a 'long' list of info for each file. '-A' requests that hidden files (and directories) be shown --- other than '.' and '..'. '-p' requests that directories be indicated by an ending slash (/). ..................... $DATETIME ............................ " >> "$OUTFILE" ###################### ## Show the list. ###################### ## . $HOME/.gnome2/nautilus-scripts/.set_VIEWERvars.shi . $HOME/.freedomenv/feNautilusScripts/set_DIR_NautilusScripts.shi . $DIR_NautilusScripts/.set_VIEWERvars.shi $TXTVIEWER "$OUTFILE" &