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
09-29-2005 03:24 AM
09-29-2005 03:24 AM
Thanks!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-29-2005 03:33 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-29-2005 03:38 AM
09-29-2005 03:38 AM
Re: SED help
Considering you can split the columns using a filed delimeter ,
example "|" (or can be any thing )
cat infile |awk -F"|" '{print $1,$2,$3}' |while read a b c;do
echo "$a `echo $b|sed 's/ /#/g'` $c"
done
Assuming the change need will be in the second column of awk o/p.
I think you can manipulate this loop and achieve what you need.
Thanks,
-BL.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-29-2005 03:45 AM
09-29-2005 03:45 AM
Re: SED help
Note: the first paren grp has 9 chars so it is checking for a space in column 10, thes next line addresses a space in column 11 up to column 20.
sed -e 's/\(.........\) \(.*\)/\1#\2/
s/\(..........\) \(.*\)/\1#\2/
s/\(...........\) \(.*\)/\1#\2/
s/\(............\) \(.*\)/\1#\2/
s/\(.............\) \(.*\)/\1#\2/
s/\(..............\) \(.*\)/\1#\2/
s/\(...............\) \(.*\)/\1#\2/
s/\(................\) \(.*\)/\1#\2/
s/\(.................\) \(.*\)/\1#\2/
s/\(..................\) \(.*\)/\1#\2/
s/\(...................\) \(.*\)/\1#\2/' output
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-29-2005 03:47 AM
09-29-2005 03:47 AM
Re: SED help
perl -p -e 'substr($_,10,10)=~s/ /#/g' yourfile
HTH
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-29-2005 03:51 AM
09-29-2005 03:51 AM
Re: SED help
Enjoy, Have FUN! H.Merijn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-29-2005 03:51 AM
09-29-2005 03:51 AM
Re: SED help
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-29-2005 05:36 AM
09-29-2005 05:36 AM
Re: SED help
I didn't see your answer when I entered mine...
Rod H
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-30-2005 06:25 AM
09-30-2005 06:25 AM
Re: SED help
"ABC A " should convert to
"ABC###A ", not to
"ABC###A###".
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-30-2005 08:45 AM
09-30-2005 08:45 AM
Re: SED help
I think, though by the time you want to go more complex, it might be better to write a real script
There are two extra problems here:
- if lines are shorter than 20 characters, you will get a warning like
substr outside of string at -e line 1, <> line 1.
- if you only check 10 chracters at offset 10, you don't look ahead to see if there are non-blanks after that character, and your defenition is not clear enough about when to change (IMHO)
but you can safeguard that
First decide, what to do if the line is shorter than 20 characters.
Then decide if the trailing non-space should be within the changed block, or if it is allowed in the trailing line
IF you have NO trailing # signs in your document, the solution is even simpler
# perl -pi -e'substr($_,10,10)=~y/ /#/;s/(#+)$/" "x length$1/e' large_file
Enjoy, Have FUN! H.Merijn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-30-2005 09:29 AM
09-30-2005 09:29 AM
Re: SED help
perl -p -e 'substr($_,10,10)=~s/ (?! *$)/#/g' largefile
By using the (?! ) construct, the pattern match will replace spaces with # unless the rest of the text is all blanks within positions 10-20.
HTH
-- Rod Hills