- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- delete lines and adding blank line
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
05-06-2002 10:45 AM
05-06-2002 10:45 AM
Anyone out there can give me a hint?
Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-06-2002 10:56 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-06-2002 11:03 AM
05-06-2002 11:03 AM
Re: delete lines and adding blank line
how about using "awk" (even though it's an old tool, and Clay and procura will present a solution in "perl" ;-)?
awk -F script.awk your.file > new.file
and the script "script.awk":
#!/usr/bin/awk
BEGIN { count=0 }
"$0" == "your case#1" { count++; if (count <= 1) print }
"$0" == "your case#2" { print; print ""; }
# end of script.awk
HTH,
Wodisch
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-06-2002 11:10 AM
05-06-2002 11:10 AM
Re: delete lines and adding blank line
Another simple way to delete multiple occurences of lines:
# sort -u filename > new_file
HTH,
Shiju
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-06-2002 11:13 AM
05-06-2002 11:13 AM
Re: delete lines and adding blank line
try doing a sort and then counting the no. of lines for that acuurances and then deleteing the count -1 for that acouurance from that file. for eg
say a file has
aa
aa
aa
aa
bb
cc
cd
dd
and what o/p you want is
aa
bb
cc
cd
dd
you can try this:
#!/usr/bin/ksh
A=`cat
B=`expr $A - 1`
cat
cat filename2 | sed -e "2,$B s/aa/ /g" > filename3
and filename3 is what you want .
Manoj Srivastava
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-06-2002 12:22 PM
05-06-2002 12:22 PM
Re: delete lines and adding blank line
It should work fine.