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-05-2004 04:25 AM
05-05-2004 04:25 AM
Delete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-05-2004 04:29 AM
05-05-2004 04:29 AM
Re: Delete
I want to delete 1st 2 lines and 1st empty space and last empty space in a text file
in a script.
ABCDEFG
-------
AANHITW
ABEAWGI
ABEGIGI
i dont need 1st 2 lines and remove spaces before and after each line.
does
sed /^\ d works and how
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-05-2004 12:32 PM
05-05-2004 12:32 PM
Re: Delete
+-- start here --+
LINE_OF_JUNK
---------
keepthis
keepthis
keepthis
+-- end here --+
You want to get rid of everything before, and including the '-----' line, and any blank lines. Yes?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-05-2004 04:08 PM
05-05-2004 04:08 PM
Re: Delete
sed '1,2d;s/ //g'
or
sed -n 's/ //g;3,$p'
thx.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-06-2004 04:52 AM
05-06-2004 04:52 AM
Re: Delete
Try this:
awk '{
if (NR>2) {
for (i=1;i<=NF;i++)
printf($i)
printf("\n")
}
}' text_file
Or the pipe format:
cat text_file | awk '{
if (NR>2) {
for (i=1;i<=NF;i++)
printf($i)
printf("\n")
}
}'
Or the script format, you must create a file (for example script.awk) with this content:
---- script.awk ----
{
if (NR>2) {
for (i=1;i<=NF;i++)
printf($i)
printf("\n")
}
}
------ end script.awk ----------
Now you can do:
awk -f script.awk text_file
Hope this helps.
Frank.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-06-2004 05:39 AM
05-06-2004 05:39 AM
Re: Delete
One appointment, with the awk solution, all spaces before and after the lines are removed but also removes all spaces between fields in the same line.
Frank.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-07-2004 08:08 AM
05-07-2004 08:08 AM
Re: Delete
Any spaces in the text posted to the forum get massacred. So please use a (.txt) file attachement to display an example of the expected input AND the desired output.
In perl the solution might be:
perl -e '<>;<>;while(<>){s/^\s+//;s/\s+$/\n/;print unless ($_ eq ""
)}' < old-file > new-file
in english:
read and forget a line
read and forget an other line
loop while lines
replace leading spaces with nothing
replace trailing spaces with a newline
print unless it is an empty line
Be sure to reply with attached test if this is not what you wanted.
hth,
hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-07-2004 03:28 PM
05-07-2004 03:28 PM
Re: Delete
dd
dd
:wq!
:)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-11-2004 03:45 AM
05-11-2004 03:45 AM
Re: Delete
:)