problem with IFS


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting problem with IFS
# 1  
Old 12-22-2006
problem with IFS

hi, Smilie
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
# 2  
Old 12-22-2006
Not to belabor the obvious, but the value in IFS is in IFS. You need to quote it.
echo IFS = "$IFS"
# 3  
Old 12-22-2006
Ok,
even if i give like this
echo IFS = "$IFS"
I am getting
IFS=
as the result

cheers
RRK
# 4  
Old 12-22-2006
Set the value in IFS and then echo it.
# 5  
Old 12-22-2006
Hm, interesting. I tried that and I got nothing either. I even tried echo \"$IFS\". But it works just as it should. I read in a colon seperated file and it was absolutely fine.
# 6  
Old 12-22-2006
Hi anbu,

Already i set IFS=":"

see the following example

output_args_one_per_line()
{
for arg
do echo "[$arg]"
done
}
IFS=":"
var=" a b c "
output_args_one_per_line $var

Its working fine.
But the only problem is when i am trying to access $IFS a blank line is being dispalyed.

what might be the cause? Smilie

cheers
RRK
# 7  
Old 12-22-2006
It works for me.
Code:
$
$
$ IFS=":"
$ echo IFS=$IFS
IFS=
$ echo IFS="$IFS"
IFS=:
$
$
$ bash
bash-3.00$ IFS=":"
bash-3.00$ echo IFS=$IFS
IFS=
bash-3.00$ echo IFS="$IFS"
IFS=:
bash-3.00$

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Problem in passing IFS array to SQL Query

Hi, I have created a shell script that reads line from text file and insert into DB table. I have used IFS to separate the line text. Looks IFS is splitting text properly but while passing one of the values that has special characters in it to query, it is giving weird issue. Below is my... (2 Replies)
Discussion started by: yuvi
2 Replies

2. Shell Programming and Scripting

Remote while IFS

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

3. Shell Programming and Scripting

Not able to understand IFS

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

4. Shell Programming and Scripting

Bash IFS

I am using bash and resetting IFS as below when reading the command line arguments. I do this so I can call my script as in Ex1. Ex1: ./synt2d-ray3dmod.bash --xsrc=12/20/30 This allows me to split both sides so that when I do "shift" I can get 12/20/30 What I do not understand is... (21 Replies)
Discussion started by: kristinu
21 Replies

5. Shell Programming and Scripting

Nested ifs

hi I keep getting an error with this nested if statement and am getting the error unexpected end of file, can anyone help me as to why this wont execute? #!/bin/bash #script to check wether the -i -v statements run correctly removeFile () { mv $1 $HOME/deleted }... (3 Replies)
Discussion started by: somersetdan
3 Replies

6. Shell Programming and Scripting

read and IFS

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

7. Shell Programming and Scripting

regarding IFS=

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

8. UNIX for Dummies Questions & Answers

Help on IFS command!

Hi! I am working in korn shell. I want to reset the dimiliter for the set command to "|" but instead of a command prompt return I am getting something as below After issuing the command I am getting this....as if the shell is expecting something else. Can anybody suggest what's the problem. ... (2 Replies)
Discussion started by: udiptya
2 Replies

9. UNIX for Dummies Questions & Answers

IFS variable

How can I set the value for IFS variable (2 Replies)
Discussion started by: mahabunta
2 Replies

10. UNIX for Dummies Questions & Answers

the IFS variable

Hi all, Ok os heres my situation. I have created a database style program that stores a persons info (name,address,phone number etc.) in a file ("database"). after i read in all the values above, i assign them to a line variable: line="$name^$address^$phonenum" >> phonebuk as you can see... (1 Reply)
Discussion started by: djt0506
1 Replies
Login or Register to Ask a Question