First off, i'd like to state for the record that i usually skip threads with "urgent" in their title out of habit. If you have an urgent demand for work you can't do on your own please consider hiring an expert.
Ok, having said this, it would also be a nice gesture to enclose code in "code"-tags. This is what they are for and they are here for a reason - perhaps for the same reason the telephone directory is printed in a tabular, formatted way instead of a stream of names and numbers: READABILITY.
Now back to the problem. I took the liberty to reformat your script a little:
Quote:
Originally Posted by Satyak
The first thing i notice is a useless use of "grep". Your goal is to limit your operation to all lines starting with a "[" character, yes? (If this is not the case your script is just wrong.) This could also be done in a sed (awk, ...) script:
A second thing is the - quite antiquated - use of backticks. Do NOT use them any more! We are in the 21st century now, we do not use morse code (we have picture telephones now), horse-pulled carts (we have automobiles) and we do not use backticks for similar reasons - we have the "$(....)" construct, which can be nested and even enclosed in normal double quotes.
(As an aside: some hold that backticks are backwards compatible with older shells. True. I hope these are writing their scripts in cuneiform writing on clay tablets to be "backwards compatible" with sumeric texts. Antiquity has ended - get over it.)
In this case not even the "$(....)", which opens a subshell, is necessary. There are enough powerful shell textprocessing commands to cut character 3-20 out of a string:
You might want to find out what a big impact on execution time this has by reading this thread.
But in your case even this is not necessary because it can be done inside the sed script we already use to filter for lines:
which does the same as the shell construct: replace the complete line with characters 3-20 and put it to <stdout>. This is what is left of your script, it will do exactly the same as the shell script you presented here: it takes every line which starts with "[" and extracts
If doesn't do what you want it to do you might tell us what your goals are and we might find out together.
I have a string like below. Now i want to split this string like below and put the value in the array using awk. I am able to do it using bash but getting no clue for doing it in awk
O/P
A=0
A=01
A=014
A=0143
A=01438
A=014387
A=0143876
A=01438765
A=014387650
... (7 Replies)
Hello
I have a script:
path=test1
echo "${path%?}"
till this the program is successful in deleting hte last character i.e. "1" and displays an output --> test. After this how can i save this output to another variable. (2 Replies)
Hi ,
I have input file and i want to extract below strings
<msisdn xmlns="">0492001956</ msisdn> => numaber inside brackets
<resCode>3000</resCode> => 3000 needs to be extracted
<resMessage>Request time
getBalances_PSM.c(37): d out</resMessage></ns2:getBalancesResponse> => the word... (14 Replies)
Hi,
I'm running Redhat Entreprise. My / is 0% available. I don't know what processes are keeping writting to files. I don't know where to check.
Please help. (3 Replies)
Dear friends, Please help me to resolve the problem below,
I have a file with following content:
date of file creation : 12 feb 2007
====================
= name : suresh
= city :mumbai
#this is a blank line
= date : 1st Nov 2005
====================
few lines of some text
this... (7 Replies)
Hi
I'm trying to find a way to search a text file for a specific string.
I have a file which contains i.p. addresses and port numbers in the following format:
'ip="www.xxx.yyy.zzz"'
'port="xx""'
I want to print only the parts between the double quotes for use in seperate variables,... (4 Replies)
Hi
How can i compare a string using if statement in a script?
For eg:
I have
filename="abc.sh"
if ;then
{
.......
.......
}
fi
but this doesnot work .. How will i execute this ??
Thanks in advance (1 Reply)
Hi all
I am trying this simple command:
a="abc abc"
echo $a
output is: abc abc
But expected output shoould be :abc abc
i.e spaces in real string are geting truncated to one space everytime.
Plz Help. (4 Replies)
I have a script that converts a file into an html table. This script works fine for a 1 column table. However, I'm trying to do this for a multi-column table. My input file will look something like this:
a b c
d e f
g h i
My script basically works by taking in each line and putting that... (2 Replies)