removing items from a file with batch


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting removing items from a file with batch
# 1  
Old 11-03-2008
Bug removing items from a file with batch

Please assist with awk scirpts:

I need to remove items from a file in a batch:

The file that I will remove from has the following format:

abc00tef:10.81.12.3
abc01tef:10.81.12.3
abc02tef:10.81.12.3
abc03tef:10.81.12.3
abc04tef:10.81.12.3
abc05tef:10.81.12.3


I have a file which is in following format, and will remove line from above file.
the script will look for field before colon(Smilie and will remove entire line.

abc00tef
abc01tef
abc02tef

so from the original file will have:

abc03tef:10.81.12.3
abc04tef:10.81.12.3
abc05tef:10.81.12.3


Thanks
# 2  
Old 11-03-2008
file1 is the original - file2 has the list of items to remove
Code:
grep -v -f file2  file1 > newfile

# 3  
Old 11-03-2008
Hammer & Screwdriver

Jim M's solution is probably the simplest and most straight-forward.

To do in awk, one approach would be to
load the values into an array
then read full file; based on if your phrase is in the array,
then write or don't write the data out
# 4  
Old 11-10-2008
I tried the this approach but I am getting the following error:

grep: illegal option -- f
Usage: grep -hblcnsviw pattern file . . .
# 5  
Old 11-10-2008
Hammer & Screwdriver grep... maybe egrep

Try the same, but use egrep instead of grep.
# 6  
Old 11-10-2008
Thanks, egrep worked, thank you very much.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Renaming batch by removing substring

I wish to rename all files ending in .txt by removing .tex. Currently I have me@me-Inspiron-518:~$ ls a.tex.txt bin b.tex.txt c.tex.txt Desktop Documents Downloads d.tex.txt Music Pictures Public Templates VideosDesired outcome me@me-Inspiron-518:~$ ls a.txt ... (2 Replies)
Discussion started by: Xubuntu56
2 Replies

2. Shell Programming and Scripting

Removing duplicate items from an array

Hello Experts, I am trying to write a shell script to find duplicate items in an array, this is what i have tried : #!/bin/bash echo "This is another sample Progg to remove duplicate items from an array" echo "How many number do you want to insert" read n for (( i=0; i<$n; i++ )) do ... (5 Replies)
Discussion started by: mukulverma2408
5 Replies

3. Shell Programming and Scripting

sed to delete items in an array from a file

I need to create a shell script to delete multiple items (Strings) at a time from a file. I need to iterate through a list of strings. My plan is to create an array and then iterate through the array. My code is not working #!/bin/bash -x declare -a array=(one, two, three, four)... (5 Replies)
Discussion started by: bash_in_my_head
5 Replies

4. Shell Programming and Scripting

Need help with a script to grep items in one file from another file

I have one master file "File1" with all such info in it. I need to grep each object under each list from another file "File2". Can anyone help me with a script for this. File 1 ------ List 1 Object 1 Object 2 List 2 Object 3 Object 1 List 3 Object 2 ... (5 Replies)
Discussion started by: Sam R
5 Replies

5. Programming

Removing Items In A ListView

Hi everyone! So I have a listView on my Form named "officeView" I already have the code to add and update info into it, but Im having troubles deleting items out of it. :/ Now I know how to delete an Item from the listView, but I want the item before the deleted item to become automatically... (0 Replies)
Discussion started by: romeo5577
0 Replies

6. Shell Programming and Scripting

finding missing items in file

I have a need to compare 2 files, then print results to file. Need to find items from file2 that are not found in file 1. thanks in advance! example: file 1: abcde=12 fffff=6 bbbb=35 file2: abcde=12 fffff=6 bbbb=35 ccccc=10 kkkkk=45 (8 Replies)
Discussion started by: discostu
8 Replies

7. Shell Programming and Scripting

Deleting double items in file

Hi, i need a script, which deletes doulbe items in a file. My file looks like: - - - xxx xxx G123 G234 G234 G234 o o ... First i want to sort the file an then i want to delete double items. Can anyone help me. I work under solaris10. (3 Replies)
Discussion started by: free2k
3 Replies

8. Shell Programming and Scripting

awk between items including items

OS=HP-UX ksh The following works, except I want to include the <start> and <end> in the output. awk -F '<start>' 'BEGIN{RS="<end>"; OFS="\n"; ORS=""} {print $2} somefile.log' The following work in bash but not in ksh sed -n '/^<start>/,/^<end>/{/LABEL$/!p}' somefile.log (4 Replies)
Discussion started by: Ikon
4 Replies

9. Shell Programming and Scripting

removing items with repeated first 3 character

AWK help: I have a file with following format. I need to remove any entries which are repeated based on first 3 characters. So from the following files I need to remove any entries start with "mas". mas01bct mas02bct mas03bct mas01bct mas01bct mas01bct mas11bct mas01bct mas01bct... (11 Replies)
Discussion started by: amir07
11 Replies
Login or Register to Ask a Question