LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-10-2009, 04:14 AM   #1
pramod.srk
Member
 
Registered: Feb 2009
Posts: 47

Rep: Reputation: 15
Linux command help


Dear All,
Getting error
./Outline.sh: line 30: line: command not found

code:
while str="`line`"; do
echo $str
done < Outline.txt

"while linestr="`line`"; do" is the line number 30.

I am executing the shell script as follows
$Outline.sh

Any idea why the command not found error is coming.

Thanks and Regards
Pramod
 
Old 11-10-2009, 04:22 AM   #2
indiajoe
Member
 
Registered: Jan 2009
Location: India
Distribution: Porteus atma
Posts: 84

Rep: Reputation: 21
Hi Pramod,
I script is working fine. Just check whether the line command is available on your machine.
-Cheers
indiajoe

Last edited by indiajoe; 11-10-2009 at 04:47 AM. Reason: Made terrible mistake in post
 
Old 11-10-2009, 05:52 AM   #3
pramod.srk
Member
 
Registered: Feb 2009
Posts: 47

Original Poster
Rep: Reputation: 15
Thanks for replying.
I checked the command line in My OS. It is not available in Linux.
$which line
[ismp_app@ysmp101 ~]$ which line
/usr/bin/which: no line in (/usr/lib64/qt-3.3/bin:/usr/kerberos/bin:/usr/local/weblogic/jrockit310_160/bin:/usr/local/bin:/bin:/usr/bin

Any idea .. how to configure line command in RHEL-5.


Thanks and Regards
Pramod
 
Old 11-10-2009, 08:17 AM   #4
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
From the man page:
Quote:
The line command is part of the util-linux-ng package and is available from
ftp://ftp.kernel.org/pub/linux/utils/util-linux-ng/.
So--first try to find it with your package manager---otherwise download it.

But, what wrong with the "read" command? (I haven't had enough coffee to understand how "line" is differnet."
 
Old 11-10-2009, 11:59 AM   #5
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
Moved: This thread is more suitable in <Programming> and has been moved accordingly to help your thread/question get the exposure it deserves.
 
Old 11-10-2009, 11:28 PM   #6
pramod.srk
Member
 
Registered: Feb 2009
Posts: 47

Original Poster
Rep: Reputation: 15
Thanks for the reply.
I checked the differences between line and read command.
I used read command to read the line from file.
From this line i need to create a file which is used for awk.

Code :
while read linestr; do
param1=`echo $linestr | sed -e 's/^\(.*\)\;\(.*\)\|\(.*\)$/\1/'`
param2=`echo $linestr | sed -e 's/^\(.*\)\;\(.*\)\|\(.*\)$/\2/'`
param3=`echo $linestr | sed -e 's/^\(.*\)\;\(.*\)\|\(.*\)$/\3/'`
echo '/'$param2'/{printf("'$param3' at %s\\n", substr($0,0,20))}' >> temp.sed
done < input.txt


The file input.txt looks like this
manager;2909,Order_MAIL : Invalid Mail Address|!manager,ERROR,Notice_MAIL:Invalid Mail Address found.
manager;ORA-2023|!manager,ERROR,ORA-04031 Occured.
manager; : Delete failed|!manager,ERROR,DatabaseGarbageCollect : Fail delete user id
MakeAllMailList;ORA-|!MakeAllMailList,ERROR,MakeAllMailList:Fail make AllMailList
Set;ORA-|!PlanSet,ERROR,PlanSet:Fail AccountSignupPlan PlanSet


Here i am getting proper values for param1 and param2. However i am getting empty for param3.

I am not able to find why i am not getting param3.
I did googling found the website
http://www.grymoire.com/Unix/Sed.html
but not able crack.

Please help.


Thanks and Regards
Pramod
 
Old 11-10-2009, 11:34 PM   #7
ghostdog74
Senior Member
 
Registered: Aug 2006
Posts: 2,697
Blog Entries: 5

Rep: Reputation: 244Reputation: 244Reputation: 244
the way you are doing it is so messy. If you want to pass things to awk, you might as well learn and get know how to use awk, because the above can be done in one awk script nicely and easily. Show how your output looks like in the end, ie what you want to get from the input file.
 
Old 11-11-2009, 12:22 AM   #8
pramod.srk
Member
 
Registered: Feb 2009
Posts: 47

Original Poster
Rep: Reputation: 15
The sed statements create a file in /tmp directory.
It contents are as follows
/2909,Notice_MAIL : Invalid Mail Address|!manager,ERROR,Notice_MAIL:Invalid Mail Address found./{printf(" at %s\\n", substr($0,0,20))}

I wanted to get the content as
The sed statements create a file in /tmp directory.
It contents are as follows
/30034,Notice_MAIL : Invalid Mail Address|!manager,ERROR,Notice_MAIL:Invalid Mail Address found./{printf("Notice_MAIL:Invalid Mail Address found. at %s\\n", substr($0,0,20))}


The text written in block is not getting populated from the text file.
 
Old 11-11-2009, 07:25 AM   #9
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
I am not sure what you want to do.

If you have lines of the format "string1;string2|string3" and you want to print "<string3> at <first 20 chars of string2>" it can be done like this
Code:
#!/bin/bash
IFS=';|'
while read line
do
    array=($line)
    echo "${array[2]} at ${array[1]:0:20}"
done < input.txt
unset IFS
Is there any particular reason why you are using /bin/sh rather than /bin/bash?
 
Old 11-13-2009, 03:25 AM   #10
pramod.srk
Member
 
Registered: Feb 2009
Posts: 47

Original Poster
Rep: Reputation: 15
Can you tell me what the following code will do.
code

Code:
param1=`echo $linestr | sed -e 's/^\(.*\)\;\(.*\)\|\(.*\)$/\1/'`
param2=`echo $linestr | sed -e 's/^\(.*\)\;\(.*\)\|\(.*\)$/\2/'`
param3=`echo $linestr | sed -e 's/^\(.*\)\;\(.*\)\|\(.*\)$/\3/'`
Please give me the example.

I am not able to understand the code.
 
  


Reply



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
URGENT! Is there any command to get a history command lines and time in SUSE Linux.? igsoper Linux - Software 5 06-25-2009 02:14 AM
LXer: The Linux Command Shell For Beginners: Fear Not The Command Line! LXer Syndicated Linux News 0 12-22-2008 06:30 PM
Translating windows pscp command to linux scp command help robward Linux - General 2 01-17-2008 06:02 AM
Require Linux/Perl equivalent command for windows Command alix123 Programming 7 08-19-2005 02:23 AM
unix command to linux command leonidas Linux - General 1 09-10-2004 12:40 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:38 AM.

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
Open Source Consulting | Domain Registration