LinuxQuestions.org
Review your favorite Linux distribution.
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 01-15-2013, 06:12 AM   #16
allend
Senior Member
 
Registered: Oct 2003
Location: Melbourne
Distribution: Slackware-current
Posts: 3,439

Rep: Reputation: 850Reputation: 850Reputation: 850Reputation: 850Reputation: 850Reputation: 850Reputation: 850

Quote:
but in my case each of them DONT HAVE have the prefexed _hnlVlogCxt
I went with what you posted in your post #13
Quote:
content of file that needed to be changed now look like

_hnlVlogCxt hnlVerilogCrossViewCheck
_hnlVlogCxt hnlVerilogGetInstCDFPropLenWidValue
_hnlVlogCxt hnlVerilogNetBitSelect
_hnlVlogCxt hnlVerilogCreateMSTestFixtureFile
I read that as the content of the file that needs to be changed.
 
Old 01-15-2013, 12:09 PM   #17
shridhar22
Member
 
Registered: Mar 2012
Posts: 39

Original Poster
Rep: Reputation: Disabled
Deleted

Last edited by shridhar22; 01-15-2013 at 12:20 PM.
 
Old 01-15-2013, 12:16 PM   #18
shridhar22
Member
 
Registered: Mar 2012
Posts: 39

Original Poster
Rep: Reputation: Disabled
Thumbs up

@Allend after searching what went wrong in previous cases was my item list( variables needing change) had leading ^ spaces that gave a different o/p what i quoted
Quote:
content of file that needed to be changed now look like

_hnlVlogCxt hnlVerilogCrossViewCheck
_hnlVlogCxt hnlVerilogGetInstCDFPropLenWidValue
_hnlVlogCxt hnlVerilogNetBitSelect
_hnlVlogCxt hnlVerilogCreateMSTestFixtureFile
However when i removed the leading spaces from variable list in my file YOUR SCRIPT WORKED PERFECT. THanks a ton for your patience and cognizance. I tried to understand what your script is doing but being a newbie i could only understand some part of it
Quote:
file=$1 #what does this do?

while read ; do #where does read come from
sed -i.bak s/"$REPLY"/_hnlVlogCxt"${REPLY#hnlVerilog}"/g "$file"; #whats the meaning of $REPLY and #
done < File.txt

Last edited by shridhar22; 01-15-2013 at 12:18 PM.
 
Old 01-15-2013, 03:14 PM   #19
allend
Senior Member
 
Registered: Oct 2003
Location: Melbourne
Distribution: Slackware-current
Posts: 3,439

Rep: Reputation: 850Reputation: 850Reputation: 850Reputation: 850Reputation: 850Reputation: 850Reputation: 850
Glad it now works for you and I applaud your willingness to learn.
Quote:
file=$1 #what does this do?
$1 is a bash positional parameter. When bash is invoked, $0 is set to the name of the file, and the positional parameters are set to the remaining arguments. In this script, the $1 is the filename passed by the 'find' command.
Quote:
while read ; do #where does read come from
'read' is a bash builtin command.In this script the construction
Code:
while read ; do
...
done < File.txt
causes one line at a time to be read from the standard input which has been redirected to come from File.txt.
Quote:
#whats the meaning of $REPLY and #
The line read is saved in the shell variable REPLY when no arguments are supplied.
The ${REPLY#hnlVerilog} is a bash parameter expansion that removes the prefix 'hnlVerilog' from the string in REPLY.

HTH
 
1 members found this post helpful.
Old 02-06-2013, 03:47 AM   #20
shridhar22
Member
 
Registered: Mar 2012
Posts: 39

Original Poster
Rep: Reputation: Disabled
Trying to run it on actual data today, didn't give me the desired result dont know why, the sed gave this notification on running
Quote:
find . -type f -exec t.sh '{}' \;
sed: -e expression #1, char 0: no previous regular expression
sed: -e expression #1, char 0: no previous regular expression
sed: -e expression #1, char 0: no previous regular expression
sed: -e expression #1, char 0: no previous regular expression
I am currently working on it again... and should soon be posting again about my findings and what went wrong. Till then i again thank the people who helped me specially allend.

Last edited by shridhar22; 02-06-2013 at 09:15 AM. Reason: I think this time i should debug it myself
 
Old 02-06-2013, 02:36 PM   #21
celticdevildog
LQ Newbie
 
Registered: Jan 2013
Location: New Mexico
Distribution: RHEL, SuSE, CentOS, bt, LFS
Posts: 21

Rep: Reputation: Disabled
What does t.sh look like? The sed command in that script is complaining.
 
Old 02-06-2013, 05:28 PM   #22
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5, Centos 5.10
Posts: 16,269

Rep: Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028
You could add
Code:
set -xv
at the top of the script. It'll show you what the parser is doing.
 
  


Reply

Tags
sed, sed regex


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
[SOLVED] sed command using variable nwalsh88 Linux - Newbie 2 12-06-2012 01:53 PM
[SOLVED] How-to include a variable's name in a regex in awk to spot command names in absolute paths Didier Spaier Programming 3 09-14-2012 04:05 AM
[SOLVED] sed help to run sed command against multiple different file names bkone Programming 2 04-16-2012 12:27 PM
how to use variable in sed command ? anandg111 Linux - Newbie 3 01-11-2012 11:27 AM
Change variable in case command New_2_Linux Programming 7 08-07-2010 07:37 PM


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

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration