Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: why is the command "chomp" used in UNIX  (Read 31742 times)

0 Members and 1 Guest are viewing this topic.

madhavi

  • Guest
why is the command "chomp" used in UNIX
« 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?

Joleen

  • Guest
Re: why is the command "chomp" used in U
« Reply #1 on: June 25, 2004, 01:16:57 PM »
I believe chomp has something to do with removing trailing spaces from a string.. er maybe I'm thinking of C programming.

googler

  • Guest
Re: why is the command "chomp" used in U
« Reply #2 on: July 21, 2004, 01:48:54 PM »
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

Addy

  • Guest
Re: why is the command "chomp" used in U
« Reply #3 on: August 04, 2004, 04:37:06 AM »
Quote
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, `"$@"' 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