( depreciated: ident [ width ] )
Print a file with the standard indent of 4:
[ / ]
[ root@acme007 ][-sh]: cat /etc/group | indent
root:x:0:root,HMUST
bin:x:1:root,bin,daemon
daemon:x:2:root,bin,daemon
sys:x:3:root,bin,adm
:
:
Print the file with a specific indent of 8:
[ / ]
[ root@acme007 ][-sh]: cat /etc/group | indent 8
root:x:0:root,HMUST
bin:x:1:root,bin,daemon
daemon:x:2:root,bin,daemon
sys:x:3:root,bin,adm
:
:
In the following script produces an output as:
:
:
interface files ...
csv files in '/data/incoming' ...
/data/incoming/HR/12002.csv
/data/incoming/HR/12003.csv
/data/incoming/HR/12004.csv
/data/incoming/HR/12005.csv
/data/incoming/GL/50003.csv
/data/incoming/GL/50004.csv
done.
csv files in '/data/outgoing' ...
/data/outgoing/HR/12001.csv
/data/outgoing/GL/50001.csv
/data/outgoing/GL/50002.csv
done.
done.
:
:
Be aware of the 'cascaded' usage of the indent command first to indent the output of the find command and then to indent the output of the whole search_csv() function.
To ensure, that error output of the find command output is also indented, the output of find to stderr has to be redirected to stdout using the 2>&1 redirection syntax.
#!/bin/sh
:
:
search_csv(){ start=$1
echo "csv files in '$start' ..."
find $start -name *.csv -print 2>&1 | indent
echo "done."
} # search_csv
main(){
in=/data/incoming
out=/data/outgoing
:
:
echo "interface files ..."
search_csv $in | indent
search_csv $out | indent
echo "done."
:
:
} # main
main $*
The main() function above could also be written as:
main(){
in=/data/incoming
out=/data/outgoing
:
:
echo "interface files ..."
{
search_csv $in
search_csv $out
} | indent
echo "done."
:
:
} # main
This is free software; see edrc/doc/COPYING for copying conditions. There is ABSOLUTELY NO WARRANTY; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.