Unix/Linux Go Back    


Shell Programming and Scripting Unix shell scripting - KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and shell scripts and shell scripting languages here.

Want to remove / and character using awk or sed

Shell Programming and Scripting


Closed Linux or Unix Question    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 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 Unix and Linux 05-20-2013
Yoda's Unix or Linux Image
Yoda Yoda is offline Forum Advisor  
Jedi Master
 
Join Date: Jan 2012
Last Activity: 22 May 2015, 10:54 AM EDT
Location: Galactic Empire
Posts: 3,402
Thanks: 240
Thanked 1,216 Times in 1,142 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 Unix and Linux 05-20-2013
Scrutinizer's Unix or Linux Image
Scrutinizer Scrutinizer is online now Forum Staff  
Moderator
 
Join Date: Nov 2008
Last Activity: 24 May 2015, 4:51 AM EDT
Location: Amsterdam
Posts: 10,206
Thanks: 332
Thanked 2,694 Times in 2,410 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 Unix and Linux 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 Linux or Unix Question

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux 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 05:11 AM.