Skip to content

Instantly share code, notes, and snippets.

@peco8
Created December 13, 2015 10:01
Show Gist options
  • Select an option

  • Save peco8/1feb918bbab63c75e002 to your computer and use it in GitHub Desktop.

Select an option

Save peco8/1feb918bbab63c75e002 to your computer and use it in GitHub Desktop.
This is tree-ish contents listing script, which outputs the contents recursively.

keep_listing.sh

What is this?

This is tree-ish contents listing script, which outputs the contents recursively.

How to use it?

keep_listing.sh $path

#!/bin/bash
list_recursive ()
{
local filepath=$1
local indent=$2
echo "${indent}${filepath##*/}"
if [ -d "$filepath" ]; then
local fname
_IFS=$IFS
IFS=$'\n'
for fname in $(ls "$filepath")
do
list_recursive "${filepath}/${fname}" " $indent"
done
IFS=$_IFS
fi
}
list_recursive "$1" " "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment