How do I use sed to return only the serial number here?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How do I use sed to return only the serial number here?
# 1  
Old 04-17-2012
How do I use sed to return only the serial number here?

I'd appreciate the help and explaining "which each switch/command does. Thanks in advance.

Code:
1742@3min# ./fmtopo|grep serial
hc://:product-id=SUNW,Sun-Blade-2500:server-id=c3admin:serial=130B58E3146/motherboard=0/cpu=0


Last edited by LittleLebowski; 04-17-2012 at 10:38 AM..
# 2  
Old 04-17-2012
Code:
./fmtopo | sed -n 's#.*serial=\([^/]*\)/.*#\1#p'

firstly we use -n to replace the use of grep. this way we print only lines we give print command. since I use a / in the command I used # as my command delimiter (you can use any character). "s" is for substitution. we substitute that regex, which actually matches the entire line but has a back reference (the black-slashed parenthesizes) which is referenced as \1 in the replacement part of the substitution command. then finally the "p" will print that line, and that line only.

Last edited by neutronscott; 04-17-2012 at 11:12 AM.. Reason: typo. fixed command more better...
# 3  
Old 04-18-2012
Thank you very much, neutron scott. I genuinely appreciate your knowledge and time.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help about bind serial number

Hello folks. Please let me understand the bind serial number. I am confuse. 13011321 ---------- Post updated at 08:32 AM ---------- Previous update was at 07:55 AM ---------- Thanks problem is solved. (1 Reply)
Discussion started by: learnbash
1 Replies

2. Shell Programming and Scripting

Return Number of Substitutions made by SED?

Hi guys, Is there any way this can be done, or return whether any substitutions have been made? thanks for any input. skinnygav (using Bash shell) (2 Replies)
Discussion started by: skinnygav
2 Replies

3. Solaris

Anyone know how to get Serial number with 1 command?

Solaris8 Anyone help? (27 Replies)
Discussion started by: frustrated1
27 Replies

4. Linux

Device serial number

Hey! I'm trying to figure out a sollution for a problem I have at my company with an Iomega MiniMax 500 GB USB disk. If i run cat /proc/bus/usb/devices I get this information: T: Bus=01 Lev=02 Prnt=04 Port=00 Cnt=01 Dev#= 5 Spd=480 MxCh= 0 D: Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00... (2 Replies)
Discussion started by: noratx
2 Replies

5. Solaris

Serial number

Hi Solarizer ;) I have face the difficulties of gathering information about the serial number of sun machine. i think its can do so easy while the machine is just one or two. But i have to administrate hundreds of sun machine. Any body knows how to gather this information by the command ? ... (4 Replies)
Discussion started by: tpx99
4 Replies

6. Solaris

Display Serial Number

Hello, I am running Solaris 9 and I need to display the serial number of my machine. How can I do this? Here is my machine info: SunOS birch 5.9 Generic_118558-09 sun4u sparc SUNW,Sun-Fire-V240 Thank you, David (5 Replies)
Discussion started by: dkranes
5 Replies

7. AIX

how to find serial number

hi how to find ( server machine )serial number throught the command in AIX thanks for your replay (3 Replies)
Discussion started by: chomca
3 Replies

8. Shell Programming and Scripting

Tape Serial Number

Hello Experts, I've got a shell script that makes the backup of the files that i want. I also have this script showing the amount of files backed up and in witch folders they are. It's only missing one thing. I got all the information beeing stored in a text file and all i've got to do is to... (6 Replies)
Discussion started by: jorge.ferreira
6 Replies

9. UNIX for Advanced & Expert Users

serial number for E3500

just wanted to know the serial number of my machine E3500 with Solaris 8 installed.Does any one who what's the command that i can use when the OS is running?( not with the Banner Command!) (3 Replies)
Discussion started by: i2admin
3 Replies
Login or Register to Ask a Question