IFS changing the variable value


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting IFS changing the variable value
# 1  
Old 02-22-2005
IFS changing the variable value

Hi,

I have a while read loop that reads files in a directory and process. The files have spaces in between, so I have the IFS=\n to to read the whole line as one file name.

The read works fine but I have a problem with another variable that I set in the beginning of the script. The variable holds the value of a directory like below

EXPDIR=/mila_nfs/edi/tecsys/test/export

After I change the IFS to \n the EXPDIR value gets changed to
/mila_ fs/edi/tecsys/test/export. See the space after /mila_ and I don't see the 'n'.

What is the solution to retain the value of the EXPDIR. I tried to assign the whole directory name again after the IFS but it is beraking again.

I am working on a Linux redhat enterprise edition 2.4.9

Any help would be highly appreciated. Thanks.
# 2  
Old 02-25-2005
pvar, please post in an appropriate forum. It took me a while to notice this post on the moderation queue.

To read a whole line at once, use:
IFS=""

It would be very odd to set IFS to a newline, but the syntax is:
IFS="
"
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Odd Behaviour for Set and IFS variable

Ok, so I'm playing around with delimters and reading files. and I came across this behaviour that I thought was a bit odd, regarding how the set command takes values... If I run this: IFS=$'-' #Assigns the - as the default delimiter for bash set I-love-my-gf-a-lot #uses set to put a bunch of... (1 Reply)
Discussion started by: Lost in Cyberia
1 Replies

2. UNIX for Dummies Questions & Answers

Changing Path Variable

Blank Blank Blank (11 Replies)
Discussion started by: pvibien
11 Replies

3. Shell Programming and Scripting

Changing IFS in bash function

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

4. Shell Programming and Scripting

Changing the variable using awk?

Dear all, I have kind of used both the awk/sed command and found them really useful. But at the necessity I am having right now, I need help. Actually, I would like to do the following in file script.sh PATH535="/eos/uscms/store/user/pooja04//analysis2012/535/mc/summer12/002/tt/" ... (2 Replies)
Discussion started by: emily
2 Replies

5. Shell Programming and Scripting

Changing variable name in for loop

Hi All please help if possible. I am a Unix novice. I have a similar question to the one posted by yonderboy at about a year ago. However his solution does not work for me. The pseudo code for my problem is as follows: for fund in 1 2 3 4 if (FTP is successfully) then FILE_SENT_fund... (2 Replies)
Discussion started by: Seether
2 Replies

6. Shell Programming and Scripting

Changing a variable Question

I have a variable: $FILENAME = /XXXX/XXXX/XXXX/file.dat I want to set another variable that will give me this: $FILENAME2=filea.dat So basically i'm chopping up variable $FILENAME. Not sure cut will do this as i'm looking at different directories so the characther length may be... (2 Replies)
Discussion started by: Pablo_beezo
2 Replies

7. Shell Programming and Scripting

resetting IFS variable

Hi, I have modified the IFS variable in the K shell program and with in the program i want to reset to the default one. How do i reset the same. e.g in the begining of the program IFS is default in the middle i changed it to IFS="|" and again i want the default value for the IFS. ... (2 Replies)
Discussion started by: vijaykrc
2 Replies

8. Shell Programming and Scripting

Confusion about IFS Variable

================================================= #!/bin/sh HOST=eux091 if && grep -q $HOST /etc/maestab then IFS=: grep -v -e "^#" -e "^$" /etc/maestab | grep $HOST | \ read HOST MAESTRO_BIN FLAG MAESTRO_USER echo $MAESTRO_BIN MAESTRO_HOME=`dirname $MAESTRO_BIN`... (7 Replies)
Discussion started by: Awadhesh
7 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