[cs631apue] cs631 Midterm project -q and -w flag
Jan Schaumann
jschauma at stevens.edu
Sat Oct 13 17:15:53 EDT 2012
ccui1 <ccui1 at stevens.edu> wrote:
> I have a question about the q and w flags.
>
> What is the meaning of non-printable words?
Not all characters can be displayed on the terminal. We usually
encounter files that only contain the characters a-z, A-Z and 0-9, but
there are many other characters, such as the newline character (commonly
represented as "\n"), the tab characters ("\t"), the various control
characters, etc.
Unix file names may contain any such character, but when we list them we
might get unexpected results when they are displayed on the terminal.
You can create files containing such characters by using control-v
(^V) followed by the key or control sequence in question. That is, to
insert a newline into a file name you could do either:
$ touch "foo
bar"
of
$ touch moo^V<return>oink
(Ie, you type "moo" followed by Control+V followed by the return key
followed by "oink".)
Similarly
$ touch moo^V^Coink
$ touch moo^V<delete>oink
$ touch "moo^V<tab>oink"
etc.
Then, compare
$ ls -l
and
$ ls -lw
By default, ls(1) replaces non-printable characters with a '?', but if
'-w' is given, it will simply print the actual character, which may
yield unexpected results.
See the isprint(3) and ascii(7) manual pages.
-Jan
More information about the cs631apue
mailing list