1.

Solve : why is the command "chomp" used in UNIX?

Answer»

hi everybody,
can u tell what is the use of the COMMAND "chomp" in UNIX?
and even can i know what is the use of @ inUNIX?
I believe chomp has something to do with REMOVING trailing spaces from a STRING.. er maybe I'm thinking of C programming.You are partially right.
It is used in perl programming as a way to remove a new line.
Heres toy code:

#!/usr/bin/perl -w

my $s = "Chomping..\n";
print $s; #print with new line
chomp ($s); #remoce the new line
print $s, "\n"; #see how i have to manually add "\n"

Hope that helps.
****************
::goOgler::
http://www.tinmith.netQuote

hi everybody,
can i know what is the use of @ inUNIX?

Did you mean: the use of '@' in shell-programming?
Here's what `info BASH` says about it:
Quote
Expands to the positional PARAMETERS, starting from one. When the expansion occurs within double quotes, each parameter expands to a separate word. That is, `"[emailprotected]"' is equivalent to `"$1" "$2" ...'.
When there are no positional parameters, `"[emailprotected]"' and `[emailprotected]' expand to nothing (i.e., they are removed).


The '@' also seperates the username from the hostname, e.g.: [emailprotected]


Discussion

No Comment Found