Want to remove / and character using awk or sed | Unix Linux Forums | Shell Programming and Scripting

  Go Back    


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Want to remove / and character using awk or sed

Shell Programming and Scripting


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 05-20-2013
aix_admin_007 aix_admin_007 is offline
Registered User
 
Join Date: Oct 2012
Last Activity: 4 April 2014, 12:15 PM EDT
Posts: 35
Thanks: 15
Thanked 1 Time in 1 Post
Want to remove / and character using awk or sed

Below i am trying to remove "/" and "r" from the output, so i need output as:
hdiskpower3
hdisk0
hdisk1


Code:
#inq | grep 5773 | awk '{print $1}' | sed 's/dev//g' | awk -F"/" '{$1=$1}1'
.....................................................//rhdiskpower0
//rhdiskpower1
//rhdiskpower2
//rhdiskpower3
//rhdisk0
//rhdisk1
//rhdisk2
//rhdisk3
//rhdisk4
//rhdisk5
//rhdisk6
//rhdisk7
//rhdisk8
//rhdisk9
//rhdisk10
//rhdisk11
//rhdisk12
//rhdisk13
//rhdisk14
//rhdisk15
//rhdisk16
//rhdisk17
//rhdisk18
//rhdisk19

Sponsored Links
    #2  
Old 05-20-2013
Yoda's Avatar
Yoda Yoda is offline Forum Advisor  
Jedi Master
 
Join Date: Jan 2012
Last Activity: 22 October 2014, 8:12 PM EDT
Location: Galactic Empire
Posts: 3,387
Thanks: 235
Thanked 1,209 Times in 1,135 Posts

Code:
sed 's#//r##'

The Following User Says Thank You to Yoda For This Useful Post:
aix_admin_007 (05-20-2013)
Sponsored Links
    #3  
Old 05-20-2013
Scrutinizer's Avatar
Scrutinizer Scrutinizer is offline Forum Staff  
Moderator
 
Join Date: Nov 2008
Last Activity: 25 October 2014, 12:38 PM EDT
Location: Amsterdam
Posts: 9,549
Thanks: 285
Thanked 2,426 Times in 2,174 Posts
Try:

Code:
inq | awk -F'[/ ]' '/5773/{print $4}'

or

Code:
inq | awk '/5773/{sub(/.*\//,x,$1); print $1}'

The Following User Says Thank You to Scrutinizer For This Useful Post:
aix_admin_007 (05-20-2013)
    #4  
Old 05-20-2013
aix_admin_007 aix_admin_007 is offline
Registered User
 
Join Date: Oct 2012
Last Activity: 4 April 2014, 12:15 PM EDT
Posts: 35
Thanks: 15
Thanked 1 Time in 1 Post
Great worked perfect.....
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Need to remove a character using sed ranjancom2000 Shell Programming and Scripting 8 06-20-2012 11:35 AM
any savant ? using AWK/SED to remove newline character between two strings : conditional removal sieger007 Shell Programming and Scripting 4 03-02-2011 11:18 PM
How to remove space in sed for / character vasanth_vadalur Shell Programming and Scripting 3 06-17-2009 09:09 AM
sed: remove first character from particular line hkansal Shell Programming and Scripting 6 06-11-2009 02:47 AM
sed to remove character [' manishabh Shell Programming and Scripting 2 08-29-2008 11:28 PM



All times are GMT -4. The time now is 01:25 PM.