hii every one can anybody help me writing shell script with this,
i have a file ...
amit
arun
vivek
and i want to read something from the user and print next to amit or arun in certain column.. like
amit 23-wall street 2000
arun 34343
vivek 4758
is it possibe with awk command.
can u please help.
joeyg
2
awk can format output (as one possible solution)
please show input file and desired output file
actually i was trying to use a notepad as database..
like ..
name adress phonnum sex
amit 22-wall 1213 male
alena 12-asd 1243 female
actually. i want to take detail from user and place them as shown above..
can u please help.
Play around with something like:
awk '
BEGIN { printf "Enter your name adress phonenum sex: "
getline name < "-"
s=substr(name,1,match(name," ")-1)
}
$0==s{print name;next}
{print}' file
can u please elaborate the code ...
thanks
awk '
BEGIN { printf "Enter your name adress phonenum sex: "
getline name < "-"
s=substr(name,1,match(name," ")-1)
}
$0==s{print name;next}
{print}' file
The code was just an example, left for you to adjust it for your own taste and not as a solution but here we go:
BEGIN { printf "Enter your name adress phonenum sex: "
getline name < "-"
s=substr(name,1,match(name," ")-1)
}
Ask for a name etc. and substract the name (first word till the first space).
$0==s{print name;next}
If we match the name print the name , adress etc.
{print}'
This prints the other lines.
Hope this helps.
Regard
it has been great help to me
thanks