Computer Hope
Software => BSD, Linux, and Unix => Topic started by: madhavi on June 11, 2004, 07:43:30 AM
-
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.net
-
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:
Expands to the positional parameters, starting from one. When the expansion occurs within double quotes, each parameter expands to a separate word. That is, `"$@"' is equivalent to `"$1" "$2" ...'.
When there are no positional parameters, `"$@"' and `$@' expand to nothing (i.e., they are removed).
The '@' also seperates the username from the hostname, e.g.: addy@MyComputer