need solution for scripting

hi all,

i would like to add on the print command to prompt user to enter a value and store inside the variable name as $inName
after that the value will replace the existing line for ${METRICA_DIR}/TechnologyPacks/Spool/2030324032
i'm new in scripting, could anyone give me some hint for sripting?

tmpfile=/tmp/tmpfile.$$

for file in loaderconfiguration*.xml
do
sed 's|${METRICA_DIR}/TechnologyPacks/Spool/2030324032|$inName|g' $file > $tmpfile
mv $tmpfile $file
done

thanks

Hi,

Iam new to Shell programming and i want to Display the same lines in a file which is appearing more than once.

Here is a file format,

WERTFRT|1234567890
ASDFFGU|1230986545
WERTFRT|1234567890
CVBNMKL|7685645385

Here 1st and 3rd lines are same and i need to select and write it in to seperate file.
please help me.

Thanks in advance.

hi KKC,

please you double quote <"> instead of single quote <'> in your sed command, then it should be ok.

sorry i can't get you mean,
i wanted add on such like

print "what is your directory : ";
then the answer is storing to &inName

and the sed will replace the &inName to ${METRICA_DIR}/TechnologyPacks/Spool/2030324032

sed 's|${METRICA_DIR}/TechnologyPacks/Spool/2030324032|$inName|g' $file

Thanks in advance

Hi KKC,

summer_cherry was asking you to replace the single codes in the sed command with double codes.

sed "s|${METRICA_DIR}/TechnologyPacks/Spool/2030324032|$inName|g" $file 

==========
Thanks,
Karthikeyan.

hi

:slight_smile: thanks for the advise~, what is the different withe replace the single codes in the sed command with double codes?:eek:

many thanks

You can do something like this--

echo "Enter the file/dir name"
read file

then do the replacements here-
sed "s|${METRICA_DIR}/TechnologyPacks/Spool/2030324032|$inName|g" $file

Thanks

when you want the value of the variables to be substituted, you need to specify the expression in double codes.

==========
Thanks,
Karthikeyan.

You getting the directory name in the variable file.
and then you are using it as the filename ???
I guess this will create confusion. Pls post with care.

==========
Thanks,
Karthikeyan.

:eek::eek:confusing.... can more clearly?

Thanks

:D:Dthanks...

tmpfile=/tmp/tmpfile.$$

for file in loaderconfiguration*.xml
do
echo "what is the path:";
read $path;
sed "s|${METRICA_DIR}/TechnologyPacks/Spool/2030324032|$path|g" $file > $tmpfile
mv $tmpfile $file
done

any changes need to change which is highlighter with red colour...
give some advise and hint please... :confused:

many thanks...:):slight_smile:

Hi KKC,

are you getting any error ?
anyprobem with the execution, why do you want to changethe highlighted part ?

==========
Thanks,
Karthikeyan.

FYI:

"single codes" is correctly spelled "single quotes". :slight_smile:

Hi Karthikeyan,

it doesn't replace this "${METRICA_DIR}/TechnologyPacks/Spool/2030324032" with my input result.... anything do i miss out??:confused:

thanks
kkc