- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- add new line script
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
08-23-2002 10:01 PM
08-23-2002 10:01 PM
Suppose if i have a file that contains 5 fields like :
350 34 1 2.1 3.1
350 35 1 2.2 2.3
350 36 1 2.3 1.3
400 37 1 2.4 5.3
400 38 1 2.5 2.2
401 39 1 2.6 3.5
401 40 1 2.7 5.1
401 41 1 2.8 2.2
And if i want to insert a blank line after every change in the first field for example in this case add a new line between 350 and 400 then 400 and 401 and so on for the whole file how do I do it. Either a one line awk or sed or a script ? Please help
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2002 12:53 AM
08-24-2002 12:53 AM
Re: add new line script
you can manage this with a simple script:
for i in `cat input_file`
do
echo "$i \n"
done
---> echo " \n" will give an extra blank line after the original line....
Allways stay on the bright side of life!
Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2002 01:55 AM
08-24-2002 01:55 AM
Re: add new line script
Thanks a lot for the response...but this didn't help...This gives a new line after every field. What i need is something like a blank line seperator after 3 records of 350, after 2 records of 400 and after 3 records of 401. i.e. After every change in the value of the first field. Please help...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2002 02:08 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2002 02:08 AM
08-24-2002 02:08 AM
Re: add new line script
cat yourfile |
awk 'BEGIN { x = $1;}
{
y=$1;
if ( y == x ) print $0;
else {
print "\n$0";
x=y;
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2002 02:33 AM
08-24-2002 02:33 AM