Other way aside from putting more PIPES (|)


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Other way aside from putting more PIPES (|)
# 1  
Old 09-22-2014
Other way aside from putting more PIPES (|)

I already manage to get the output that i want.. but wat if removing all the pipes and convert it 1 liner with less pipes. My command below can get the ouput that i want. i just want to remove the pipes or less pipes.

Code:
#cat file1
us-west-2a running i-3397a421 192-11-1-10.us-west-2.compute.internal 
us-west-2a running i-33af9c21 192-11-1-11.us-west-2.compute.internal 

Command i use:
 cat file1 |awk '{gsub("ip-","",$4)}1'|awk '{gsub("-",".",$4)}1'|awk '{gsub(".us.west.2.compute.internal","\t",$4)}1'

Output:
#cat file1
us-west-2a running  i-3397a421  192.11.1.10        None
us-west-2a running i-33af9c21 192.11.1.11        None

# 2  
Old 09-22-2014
A single awk statement perhaps ? :
Code:
awk ' { gsub("ip-","",$4);gsub("-",".",$4);gsub(".us.west.2.compute.internal","\t",$4) } 1'  file1.txt

This User Gave Thanks to Peasant For This Post:
# 3  
Old 09-22-2014
look goods to me.. Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Hardware

Putting an old hd in a new computer

What are the steps you need to take when you put an old HD in a new computer? I just did this. Every time it makes it to the windows boot screen then restarts. I have a bunch of old engineering software that is not compatible with the newer versions of windows. I figured this out after I bought... (6 Replies)
Discussion started by: cokedude
6 Replies

2. UNIX for Dummies Questions & Answers

Putting $$ before filename

Hello , I am searching a directory for a file and have to assign the filename to a variable . The variable must have form $$filename So my code is echo "'$$filename='`ls -lrt *PreMatch*.csv| head -1 | nawk '{print $9}'`" however $$ is converting to a number . How could I make it $$... (3 Replies)
Discussion started by: Pratik4891
3 Replies

3. Shell Programming and Scripting

putting two images together

Hi, I generated many figures in .png format (approximately 120). Right now I need to pair the figures on a single page so that the files with the same file name (i.e. jack) that end with .matrix.png are placed on the left and .cdt.png is on the right (so jack.matrix.png with jack.cdt.png... (6 Replies)
Discussion started by: kylle345
6 Replies

4. Programming

putting numbers behind eachother

I want to make a program where you have to insert binary numbers like this: do { iBinary = getche(); }while(iBinary == 1 || iBinary == 0); after you get the numbers I want them to be placed behind eachother so you will get: input: 1 1 0 1 output: 1101 (7 Replies)
Discussion started by: metal005
7 Replies

5. UNIX for Dummies Questions & Answers

putting Linux on an old windows PC

Hello, I was just reading around these forums when I had an idea, without being able to really answer my question for myself due to some circumstances, so hopefully someone can give me a hand. I have an old desktop PC that has served me very well. I got an Asus G73JH though, so I mostly used the... (2 Replies)
Discussion started by: Patriots12
2 Replies

6. Shell Programming and Scripting

Putting a character between two other characters?

I need to separate Pascal style identifiers (TheyLookLikeThis) into words separated by an underscore (_). I've tried sed 's//&_&/' but this won't work (obviously). I'd love some help. (4 Replies)
Discussion started by: Ilja
4 Replies

7. UNIX for Dummies Questions & Answers

Putting Wallpaper on the Desktop

How do I put wallpaper from the internet on the Unix desktop? For example, I want to know how to perform the same operation as "right click-> Set as Wallpaper" on a graphics on a web page, in Windows. Thanks! :rolleyes: (3 Replies)
Discussion started by: pireifej
3 Replies

8. Filesystems, Disks and Memory

PIPEs and Named PIPEs (FIFO) Buffer size

Hello! How I can increase or decrease predefined pipe buffer size? System FreeBSD 4.9 and RedHat Linux 9.0 Thanks! (1 Reply)
Discussion started by: Jus
1 Replies

9. Programming

Putting breakpoint on core

Any one tried puting breakpoint while debugging a core file? I have been using a gdb for running it.. But unsuccessful to put a breakpoint before executing it. Any sugestion or tool for doing it would be welcomed.. Thanks :) (0 Replies)
Discussion started by: jyotipg
0 Replies

10. UNIX for Dummies Questions & Answers

Putting pC on network

How do I put a my PC with linux 7.0 on a class B network. Can someone give me info or text that will guide me? (1 Reply)
Discussion started by: Rush
1 Replies
Login or Register to Ask a Question