Using indent Utility205
1 /**************************************
2 * hello.c
3 *
4 * This file is used to demonstrate use
5 * of indent utility
6 *************************************/
7 #include
8
9 main ()
10 {
11 char string[25];
12 printf ("Enter a string of characters : ");
13 scanf ("%s", string);
14 printf ("The entered string is : %s\n ", string);
15 }
However line 6 is still not properly indented. By default the
indent
program does not
modify comment lines.
To find out which version of the
indent
program you are using, use the following com-
mand.
[root@boota ftp-dir]# indent --version
GNU indent 2.2.6
[root@boota ftp-dir]#
7.1.1Getting Started with Indent
The
indent
program may be used as a command or as a pipe. In the command mode, the
program has a general format as shown below:
indent [options] [input filename] [-o output filename]
The following two lines show the simplest use of the
indent
program. It takes
hello.c
as input file and creates
hello.c
as output file and
hello.c~
as backup file.
[root@boota indent]# indent hello.c
[root@boota indent]#
If you want to create an output file with a different name without modifying the original
file, you can use the –o option with
indent
. When multiple input files are specified,
indent
reformats each file and creates a backup file for each input file. Wild card characters
can also be used with
indent
so that you can indent all C source code files with the
indent *.c
” command.
The output of another command can also be piped into the
indent
command. The fol-
lowing command does the same thing as
indent hello.c
but writes the output on STDOUT
instead of writing it to a file.
cat hello.c | indent
Next Page >>
<< Previous Page
Back to the Table of Contents