09-06-2012
That's not the code you ran. You must have been running
echo "$*" quotes and all, otherwise you'd have never seen the pipes.
$* after the
set didn't remove the equals, it was already gone. If you ran
./script a b --arg=c, $* on line 3 wopuld be the string
a|b|--arg=c and split apart on "|=" into the arguments
"a",
"b",
"--arg", and
"c" The equals sign is already gone, deleted.
So when you do $* after that, it just smashes $1 $2 ... all together with | inbetween:
a|b|--arg|c
Now remember, $* always,
always does this, even if you don't quote it.
You just don't see it without quotes, because the shell splits it. It'd see a|b|--arg|c, give "a" as echo's first argument, "b" as echo's second argument, "--arg" as echo's third argument, and "c" as echo's fourth argument. (echo doesn't split the arguments; that's the shell's job.) echo is not controlled by IFS, and will just put spaces inbetween...
Last edited by Corona688; 09-06-2012 at 04:52 PM..
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
How can I set the value for IFS variable (2 Replies)
Discussion started by: mahabunta
2 Replies
2. Shell Programming and Scripting
hi, :)
I set IFS=":"
But when i try to echo $IFS,i am not getting any thing on the screen escept a blank line.
any help pls.
cheers
RRK (11 Replies)
Discussion started by: ravi raj kumar
11 Replies
3. Shell Programming and Scripting
hi i am a learner
can some explain "export IFS=$(echo "\n\t\a")"
i am not able to understand the functionality
please help
thanks
Satya (1 Reply)
Discussion started by: Satyak
1 Replies
4. Shell Programming and Scripting
im messing up somehwere...and can't seem to clean up the script...for it to work
objectives:
1. check for today's file, and sleep 30 secs between retries
2. only allow 5 tries before script should fail.
3. if today's file found, wait 30 seconds for it to process..
code:
count=0... (8 Replies)
Discussion started by: sigh2010
8 Replies
5. Shell Programming and Scripting
Hi,
This is out of curiosity:
I wanted to extract year, month and date from a variable, and thought that combining read and IFS would help, but this doesn't work:
echo "2010 10 12" | read y m d
I could extract the parts of the date when separated by a -, and setting IFS in a subshell:
... (3 Replies)
Discussion started by: raphinou
3 Replies
6. Shell Programming and Scripting
Given the scenario like this, if at all if have to use IFS on the below given example, how it should be used.
IFS=/
eg:
/xyz/123/348/file1
I want to use the last slash /file1 . So can anyone, suggest me how to pick the last "/" as a IFS. (4 Replies)
Discussion started by: raghunsi
4 Replies
7. Shell Programming and Scripting
Hi ,
i am in my initial learning phase of unix. i was going thru the function part.
below is the example which was there but i am not able to understand logic and the use of IFS(internal field separator)
lspath() {
OLDIFS="$IFS"
IFS=:
for DIR in $PATH ; do echo $DIR ; done
IFS="$OLDIFS"... (8 Replies)
Discussion started by: scriptor
8 Replies
8. Shell Programming and Scripting
I have a function in bash that takes arguments. does IFS work in a function or does it apply only to the main script? (1 Reply)
Discussion started by: kristinu
1 Replies
9. Shell Programming and Scripting
Hello masters of scripting,
I've been working to develop some basic monitoring scripts. I have solved one problem, but want to know how to solve the other.
I have a script that runs locally to create an output file with the Linux system kernel paramters, preceeded by the system name:
... (2 Replies)
Discussion started by: LinuxRacr
2 Replies
10. Shell Programming and Scripting
I am trying to become more fluent with the interworking of bash and minimize the number of external calls.
Sample Data. This will be the response of the snmp query.
SNMPv2-MIB::sysName.0 = STRING: SomeHostName
SNMPv2-MIB::sysObjectID.0 = OID: SNMPv2-SMI::enterprises.9.1.1745... (5 Replies)
Discussion started by: sumguy
5 Replies
LEARN ABOUT DEBIAN
ns_bindsock
Ns_Sock(3aolserver) AOLserver Library Procedures Ns_Sock(3aolserver)
__________________________________________________________________________________________________________________________________________________
NAME
Ns_BindSock, Ns_GetSockAddr, Ns_SockAccept, Ns_SockAsyncConnect, Ns_SockAsyncConnect2, Ns_SockBind, Ns_SockCloseLater, Ns_SockConnect,
Ns_SockConnect2, Ns_SockListen, Ns_SockListenEx, Ns_SockPipe, Ns_SockSetBlocking, Ns_SockSetNonBlocking, Ns_SockStrError, Ns_SockTimedCon-
nect, Ns_SockTimedConnect2, ns_pipe, ns_sockpair - library procedures
SYNOPSIS
#include "ns.h"
Ns_BindSock(arg, arg)
Ns_GetSockAddr(arg, arg)
Ns_SockAccept(arg, arg)
Ns_SockAsyncConnect(arg, arg)
Ns_SockAsyncConnect2(arg, arg)
Ns_SockBind(arg, arg)
Ns_SockCloseLater(arg, arg)
Ns_SockConnect(arg, arg)
Ns_SockConnect2(arg, arg)
Ns_SockListen(arg, arg)
Ns_SockListenEx(arg, arg)
Ns_SockPipe(arg, arg)
Ns_SockSetBlocking(arg, arg)
Ns_SockSetNonBlocking(arg, arg)
Ns_SockStrError(arg, arg)
Ns_SockTimedConnect(arg, arg)
Ns_SockTimedConnect2(arg, arg)
ns_pipe(arg, arg)
ns_sockpair(arg, arg)
_________________________________________________________________
DESCRIPTION
These functions ...
SEE ALSO
nsd(1), info(n)
KEYWORDS
AOLserver 4.0 Ns_Sock(3aolserver)