LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-24-2011, 12:45 AM   #1
kenny53067
Member
 
Registered: Jul 2011
Location: Rio Grande City, Texas
Posts: 54

Rep: Reputation: Disabled
Question My script is not working right


Can anyone tell me what is wrong?

$ cat Memo20
twoliner="This is line 1.
This is line 2."
$ IFS="."
echo "$twoliner"
This is line 1.
This is line 2.
echo $twoliner
This is line 1
This is line 2

With this script both echos should display the same, but they don't.

The first echo has . at the end of sentence.
The second echo does not have an .

Last edited by kenny53067; 07-24-2011 at 01:07 AM.
 
Old 07-24-2011, 01:34 AM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,066
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
Quote:
Can anyone tell me what is wrong?

$ cat Memo20
twoliner="This is line 1.
This is line 2."
$ IFS="."
echo "$twoliner"
This is line 1.
This is line 2.
echo $twoliner
This is line 1
This is line 2

With this script both echos should display the same, but they don't.

The first echo has . at the end of sentence.
The second echo does not have an .
Firstly I can't actually see a "script" as such, and the transcript
of shell activities you posted doesn't make too much sense to me.

Is this really what you did, with the results you posted?



Cheers,
Tink
 
Old 07-24-2011, 01:43 AM   #3
kenny53067
Member
 
Registered: Jul 2011
Location: Rio Grande City, Texas
Posts: 54

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Tinkster View Post
Firstly I can't actually see a "script" as such, and the transcript
of shell activities you posted doesn't make too much sense to me.

Is this really what you did, with the results you posted?



Cheers,
Tink
This is what it looks like:
$ cat Memo20
twoliner="this is line 1.
This is line 2."
$ IFS="."
$ echo "$twoliners"
$ echo $twoliners

I added the IFS command.
 
Old 07-24-2011, 01:50 AM   #4
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,066
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
Quote:
Originally Posted by kenny53067 View Post
This is what it looks like:
$ cat Memo20
twoliner="this is line 1.
This is line 2."
$ IFS="."
$ echo "$twoliners"
$ echo $twoliners

I added the IFS command.
So where/how does the shell variable twoliners get
created/populated in your session? And looking at that
transcript the output (zippo) does look the same?



Cheers,
Tink
 
Old 07-24-2011, 02:02 AM   #5
kenny53067
Member
 
Registered: Jul 2011
Location: Rio Grande City, Texas
Posts: 54

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Tinkster View Post
So where/how does the shell variable twoliners get
created/populated in your session? And looking at that
transcript the output (zippo) does look the same?



Cheers,
Tink
I don't know what you mean created/populated.
Without the IFS command I added the output of the echos is this:
echo1 is This is line 1.
This is line 2.

echo2 is This is line 1. This is line 2.

Does this help?
 
Old 07-24-2011, 02:08 AM   #6
kenny53067
Member
 
Registered: Jul 2011
Location: Rio Grande City, Texas
Posts: 54

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by kenny53067 View Post
I don't know what you mean created/populated.
Without the IFS command I added the output of the echos is this:
echo1 is This is line 1.
This is line 2.

echo2 is This is line 1. This is line 2.

Does this help?
It works if I add $ IFS=""

I figured it out, Thanks for the help!!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
script is not working vaibhavs17 Linux - Newbie 1 08-25-2010 02:58 PM
[SOLVED] df script not working kma07 Linux - Newbie 2 07-22-2010 01:07 AM
Crontab is not working, the script is working arfal SUSE / openSUSE 6 02-08-2010 09:48 PM
SH Script not working PEACEYALL Linux - General 3 03-21-2005 09:58 AM
Help get this script working please rickenbacherus Linux - General 2 03-24-2004 07:25 PM


All times are GMT -5. The time now is 12:57 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration