- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Match Pattern and delete lines
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-28-2004 05:22 AM
тАО09-28-2004 05:22 AM
I have 2 files one containing some patterns and the other file with lines having the pattern.
I need to read both the files and delete all the lines in file2 which matches the patterns in file1.
Thanks,
Rahul
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-28-2004 05:28 AM
- Tags:
- grep
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-28-2004 05:30 AM
тАО09-28-2004 05:30 AM
Re: Match Pattern and delete lines
do
while read -r file2d
do
hit=0
hit=$(echo $file2d | grep $file1d)
if [ $hit -eq 0
echo $file2d >> /tmp/newfile2
else
echo "data reject
fi
done < /tmp/file2
done < /tmp/file1
Needs a tweak or two, but this approach might work.
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-28-2004 05:32 AM
тАО09-28-2004 05:32 AM
Re: Match Pattern and delete lines
you will have to use sed for this.
cat file1 | while read pattern
do
grep -v $pattern file2 >> /tmp/file3
mv file2 file2.old
mv file3 file2
done
Hope this helps
Prashant
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-28-2004 05:57 AM
тАО09-28-2004 05:57 AM
Re: Match Pattern and delete lines
cat file 1| while read pat1 pat2 pat3 ..
do
egrep -v "$pat1|$pat2|...$patn" file2 >> file3
..
..
..
Hope it helps
Prashant