indent

Package: WA2L/edrc 1.5.57
Section: Library Commands (3)
Updated: 22 January 2015
Index Return to Main Contents

 

NAME

indent - continuous unbuffered output with an indent

 

SYNOPSIS

edrc/lib/indent [ width [ output_channel ]]

( depreciated: ident [ width ] )

 

AVAILABILITY

WA2L/edrc

 

DESCRIPTION

continuous output of characters received via stdin with a leading indent ( width ) on each line.

 

OPTIONS

width
width of output indent. If not specified the default of 4 applies.

output_channel
if set to 1 the leading indent goes to stdout which is the default. If set to 2 the leading indent goes to stderr.

 

ENVIRONMENT

-

 

EXIT STATUS

0
no error.

 

FILES

-

 

EXAMPLES

1) indented output of a file

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
        :
        :

2) indented output in a script

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

 

SEE ALSO

edrcintro(1), cat(1), csv(3), sh(1)

 

NOTES

-

 

BUGS

-

 

AUTHOR

indent was developed by Christian Walther. Send suggestions and bug reports to wa2l@users.sourceforge.net . 

 

COPYRIGHT

Copyright © 2015 Christian Walther

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.


 

Index

NAME
SYNOPSIS
AVAILABILITY
DESCRIPTION
OPTIONS
ENVIRONMENT
EXIT STATUS
FILES
EXAMPLES
SEE ALSO
NOTES
BUGS
AUTHOR
COPYRIGHT

This document was created by man2html using the manual pages.
Time: 16:53:12 GMT, August 28, 2024