- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: sed command
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
01-17-2007 09:54 PM
01-17-2007 09:54 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2007 10:13 PM
01-17-2007 10:13 PM
Re: sed command
you can do that with sed and awk
sed : add a separator character before the string "value" => "!value" for exemple
awk : use this character as begin of line and the carriage return as separator of fields
Hope that will helps,
Cedric.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2007 10:20 PM
01-17-2007 10:20 PM
Re: sed command
not in sed/awk, but old-fashioned shell ;-)
#!/usr/bin/sh
a=1
while read record
do
if [ $a -eq 1 ]
then
value="$record"
a=`expr $a + 1`
else
count=`echo "$record" | awk '{print $3}'`
count2="`echo $count2` $count"
if [ $a -le 3 ]
then
a=`expr $a + 1`
else
echo $value $count2
a=1
count2=""
fi
fi
done < a.lis
Please also read:
http://forums1.itrc.hp.com/service/forums/helptips.do?#33 on how to reward any useful answers given to your questions.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2007 10:36 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2007 11:21 PM
01-17-2007 11:21 PM
Re: sed command
awk '
{
s1 = $0
getline
s2 = $0
getline
s3 = $0
getline
print s1, s2, s3, $0
}' 284910.txt
The following sed command will also work:
sed -n 'N;N;N;s/\n/ /g;p;d' 284910.txt
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-18-2007 01:29 AM
01-18-2007 01:29 AM
Re: sed command
I assume you only want to print the real values, no the whole text.
I added a header - if you don't need it, drop the 'BEGIN' section.
awk 'BEGIN {printf("%s\t%s\t%s\t%s\n","value","insert","update","delete")}
NF==1 {if(val) printf ("%s\t%d\t%d\t%d\n",val,ins,upd,del);val=$1}
/^Rows inserted/ {ins=$3}
/^Rows updated/ {upd=$3}
/^Rows deleted/ {del=$3}
END {if(val) printf ("%s\t%d\t%d\t%d\n",val,ins,upd,del)}' yourfile
mfG Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-18-2007 06:14 PM
01-18-2007 06:14 PM
Re: sed command
Thanz Peter, Cedric,Dennis and Peter..
I got the required output..:-)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-18-2007 06:20 PM
01-18-2007 06:20 PM
Re: sed command
nice to hear, that our solutions were valuable! Because you are new to this forum - Welcome! - I want to put your attention to its points system:
http://forums1.itrc.hp.com/service/forums/helptips.do?#28
mfG Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-18-2007 07:54 PM
01-18-2007 07:54 PM
Re: sed command
ex -s file <
EOF
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2007 08:34 AM
01-19-2007 08:34 AM
Re: sed command
Thanks, I was never able to figure out how to join multiple lines in vi until I saw this and reread the man page.
Though in visual mode, having to type ":j3" is not much easier than "JJJ"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2007 11:48 PM
01-31-2007 11:48 PM
Re: sed command
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2007 04:11 AM
02-01-2007 04:11 AM
Re: sed command
to make it easier for others to find valuable solutions for their problems, please rate the answers to your questions.
Here you'll find a description about this:
http://forums1.itrc.hp.com/service/forums/helptips.do?#33
mfG Peter