- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Removing line from text file
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
Forums
Discussions
Discussions
Discussions
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
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
04-17-2002 12:51 PM
04-17-2002 12:51 PM
I have a text file tail of that is like.
zeltweg IN CNAME zeltweg.abc.co.uk.
zeltweg IN CNAME zeltweg.xyz.co.uk.
zolder IN CNAME zolder.abc.co.uk.
zolder IN CNAME zolder.xyz.co.uk.
zonta IN CNAME zonta.abc.co.uk.
zonta IN CNAME zonta.xyz.co.uk.
zuela7 IN CNAME zuela7.abc.com.
zorzi IN CNAME zorzi.abc.co.uk.
zorzi IN CNAME zorzi.xyz.co.uk.
I would like to remove these lines from bourne shell script.
zeltweg IN CNAME zeltweg.xyz.co.uk.
zolder IN CNAME zolder.xyz.co.uk.
zonta IN CNAME zonta.xyz.co.uk.
zorzi IN CNAME zorzi.xyz.co.uk.
Sachin
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2002 12:58 PM
04-17-2002 12:58 PM
Re: Removing line from text file
If you want to delete all lines ending with "xyz.co.uk." use:
grep -v "xyz.co.uk.$" file >newfile
Darrell
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2002 01:02 PM
04-17-2002 01:02 PM
Re: Removing line from text file
cat filename | grep -v xyz > new filename
Manoj Srivastava
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2002 01:08 PM
04-17-2002 01:08 PM
Re: Removing line from text file
Use
grep -v "xyz.co.uk" filename > newfilename;mv filename filename.old;mv newfilename filename
HTH,
Jeff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2002 01:08 PM
04-17-2002 01:08 PM
Re: Removing line from text file
e.g
/zeltweg IN CNAME zeltweg.xyz.co.uk./d
/zolder IN CNAME zolder.xyz.co.uk./d
/zonta IN CNAME zonta.xyz.co.uk./d
/zorzi IN CNAME zorzi.xyz.co.uk./d
Bracket each desired pattern with /pattern/ and then end each line with 'd' - the delete command.
Now
sed -f myfile.sed oldfile > newfile
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2002 01:09 PM
04-17-2002 01:09 PM
Re: Removing line from text file
# grep -v -E '\.xyz.' filename > newfile
==> filter out any lines that has ".xyz." string.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2002 01:18 PM
04-17-2002 01:18 PM
Re: Removing line from text file
some time it is different. I had post tail of my file and so it come out xyz.co.uk but at the beginning it is different.
In sort when I had two line with same system name regarless of domain name I would like to remove second system name.
I guss i am still not explaining clearly.
Sachin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2002 01:29 PM
04-17-2002 01:29 PM
Re: Removing line from text file
last=null
for LINE in `cat file`
do
current = echo $LINE |awk '{print $1}'
if current != last
output line
fi
last=current
done
Sachin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2002 01:30 PM
04-17-2002 01:30 PM
Solutionsort oldfile | sort -k1,3 -u > newfile
The use of two sorts is intentional, I want to sort first on the entire line to force exact order and then sort on the first 3 fields and only pass lines that are unique in the first 3 fields.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2002 01:38 PM
04-17-2002 01:38 PM
Re: Removing line from text file
Your last answer works like champ. That is why you are Olympian and I am not....
Sachin