Help: deletion of record

I have created a address book file. Insertion of Record (using >> symbol)and searching of record (using grep command) into the address book is also working correctly. Now I want to delete a record into a file. Any body can help me in this case without using sed and awk18 18.
Thanks and best regards,

sed "/pattern/d" file > tmp
mv tmp file
awk ' $0 !~ /pattern/ { print > "file" } < file
perl -i -ne ' print if( $_ !~ /pattern/ ) ' file

joining this to the list,

sed -n '/pattern/!p' filename

That will only work for files with size lesser than the amount
of bytes your awk utility reads from files at a time.

Yet to verify that!

and this!

awk '{ if( !match($0, "pattern") ) { print } }' file

Sorry for the statement, i had to write without sed and awk. Please tell me the solution without sed and awk

Sorry for the statement, i had to write without sed and awk. Please tell me the solution without sed and awk

without using sed/awk? can you use grep?
if you can use grep, then

grep -v 'record_you_dont_want' file > newfile
grep -v pattern inputfile > newfile && mv newfile inputfile
{ rm inputfile && grep -v pattern > inputfile; } < inputfile

Thank u very much for giving me reply. As u know that the grep find out the whole lines where text match. How can I access the only column single value not a whole row of the file.
Thanks

This question is out of sheer curiosity, :slight_smile:

Why is that you dont want to use sed and awk which are more powerful compared to grep ?

Is that because sed and awk are not available on your node ?

:slight_smile:

Can you provide some examples?

Because i am doing some practice of using shell script commands without sed, awk, perl

e.g i am using three column name in my address book file 'name', 'phone','address'. let suppose i search by name then it display the whole line including name, phone and address of that name. If i want to display only name and phone then how it is possible.
Thanks of ur interest and help.

Thank u very much for reply. I am using three column name in my address book file 'name', 'phone','address'. let suppose i search by name then it display the whole line including name, phone and address of that name. If i want to display only name and phone then how it is possible.
Thanks of ur interest and help.

Post a sample from your data file.

Following is the data of my Addressbook

    NAME            |       TELEFONE        |       ADDRESS
    ----            |       --------        |       \-------

Shujata | 222222 | India
Selina | 555555 | Germany
Saira | 999999 | Spain
Jamil | 777777 | Spain
sujata | 069456789 | tyuiio

If i use the grep command for search the name Saira then it show me the whole line including
Saira | T 999999 | Spain

But i want to disply only name of Saira and its Telefone number and not its address. Can u help me without using awk,sed,perl

Thanks for ur interest.

grep -i "saira" file | IFS="|" read name no cntry
echo $name $cntry

If the result of grep contains more than one line then

grep -i "saira" file | while IFS="|" read name no cntry
do
   echo $name $cntry
done

Misread the question.
Post changed.

With cut (GNU coreutils) and bash:

cut -d "|" --output-delimiter "" -f1,2 <(grep Saira file)

Thank u very much for solving my problem. Can u tell me the concept of IFS and what is the order of running this command? I have read about the pipe line symbor. This type of command start processing from left to right but here the sequence is not followed. Please tell me about this concept and IFS.
Thanks and best regards,