Substitute from awk results


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Substitute from awk results
# 1  
Old 01-04-2014
Substitute from awk results

Hi,
The following awk command :

Code:
asmcmd lsdg | awk '{print $13;}' | grep -i ${SID}

return the following output . An Empty line + two lines contain "/" at the end of the line

Code:
INDEVDATA/
INDEVFRA/

I need to remove the "/" as well as the empty line.
Please advise

Thanks

Last edited by bartus11; 01-04-2014 at 03:58 PM.. Reason: Please use code tags.
# 2  
Old 01-04-2014
add to your code

Code:
sed -e 's/\///g' -e '/^$/d'

# 3  
Old 01-04-2014
You could do the whole thing in an awk program:
Code:
asmcmd lsdg | awk -v S="$SID" 'BEGIN{IGNORECASE=1}$13~S&&NF{gsub("/",x,$13);print $13}'

Use nawk instead in SunOS or Solaris
This User Gave Thanks to Yoda For This Post:
# 4  
Old 01-04-2014
I wonder how grep -i ${SID} can deliver an empty line.
What is ${SID}?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk to substitute ip without zero left padding

Hello All, I have this script to awk IP to new file. #awk '/myip|yourip/ {sub(/...\....\....\..../, newip)}1' newip=$IP existing.txt > new.txt When existing.txt has myip=192.168.123.123 and $IP has 192.168.12.12, the awk script is not working. But while I add zero left padding to $IP i.e,... (3 Replies)
Discussion started by: Shaan_Shaan
3 Replies

2. Shell Programming and Scripting

substitute with awk

When the line contains abc, it will goes to the next line and substitue the MM to NN bc 23 33 abc 23 33 ddd MM xx dff MM 33 cat xxx |awk '{if ($0~/abc/){getline;sub(/MM/,"NN")}{print}}', It doesn't show "abc 23 33 bc 23 33 ddd NN xx dff MM 33 bc 23 33 abc 23 33 ddd NN xx... (1 Reply)
Discussion started by: yanglei_fage
1 Replies

3. Shell Programming and Scripting

AWK variable substitute issue

dear, I have below file called folderlist.txt # ParentFolder environment_flag SubFolders triss 1 checksum bookstructure 1 fx 1 checksum_GMDB I have a script which which will create the folders under... (3 Replies)
Discussion started by: manas_ranjan
3 Replies

4. Shell Programming and Scripting

using awk to substitute data in a column delimited text file

using awk to substitute data in a column delimited text file hello i would like to use awk to do the following calculation from the following snippet. input file C;2390 ;CV BOUILLOTTE 2L 2FACES NERVUREES ;1.00 ;3552612239004;13417 ;25 ;50 ; 12;50000 ; ; ... (3 Replies)
Discussion started by: iindie
3 Replies

5. Shell Programming and Scripting

awk substitute variable value in nth field

I have a large csv file that looks like this: The 3rd field is a unix time stamp that I want to convert to human readable. I wrote a bash script with this code: IFS=$',' cat $1 | while read ID user DATE text flags read; do echo -e "$ID,$user,$(date -d @$DATE),$text,$flags,$read... (3 Replies)
Discussion started by: stumpyuk
3 Replies

6. Shell Programming and Scripting

how to substitute filepaths with sed or awk?

I am having the following problem. I am having a lot of files (test_1_01.hea, test_1_02.hea, etc) with the content: project_directory /net/1/d_1/5/ tmp_directory /net/1/d_1/5/ material_directory /net/1/d_1/5/ And I have to substitute the filepaths with new counted ones where the... (3 Replies)
Discussion started by: ergy1983
3 Replies

7. Shell Programming and Scripting

AWK Multiple substitute

I want to reformat the following: ID1 ID001 0 0 2 1 GG TC GG CT GG AA AA AG ID2 ID002 0 0 2 2 GG 00 AG CC GG GG TC CC I want to replace only:... (1 Reply)
Discussion started by: genehunter
1 Replies

8. Shell Programming and Scripting

Using Awk to efficiently substitute values using 3 vectors

I'm trying to efficiently combine the fields of two vectors (vectors b and c) into a new vector (vector d) as defined by instructions from a 3rd vector (vector a). So vector a has either a 1 or 2 in each field specifying which vector (b or c respectively) should go into that field. Vector a is... (4 Replies)
Discussion started by: LaTortuga
4 Replies

9. Shell Programming and Scripting

Using awk to substitute columns from one file into another

Hi, I am new to this forum and my script skills are very weak. I have this file (file 1) that contains 3 columns (tab delimited): kyle start stop john start stop joe start stop And I want to replace name (column 1) from another file. This other file has two columns, one is the... (4 Replies)
Discussion started by: kylle345
4 Replies

10. Shell Programming and Scripting

need a little help with results from awk

Hi there all, I am using a line to get some replys from my PS I do ps -ef |awk '{printf $9}' But my result is 1 big line. No spaces between the lines or someting for example:... (2 Replies)
Discussion started by: draco
2 Replies
Login or Register to Ask a Question