Selecting groups


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Selecting groups
# 1  
Old 06-28-2014
Selecting groups

I have a file with contents like

Code:
host1.domain.com:9090,host2.domain.com:9090,host3.domain.com:9090

I am looking for such an operation so that, the output should be
Code:
host1.domain.com:9090
host2.domain.com:9090
host3.domain.com:9090

And also, if the number of entries are more, the output should be same like above.
# 2  
Old 06-28-2014
Code:
akshay@Aix:~$ echo 'host1.domain.com:9090,host2.domain.com:9090,host3.domain.com:9090' | \
> tr  ',' '\n'
host1.domain.com:9090
host2.domain.com:9090
host3.domain.com:9090

Code:
tr  ',' '\n' <inputfile >outputfile

Code:
awk NF RS=',' inputfile

Code:
sed 's/,/\n/g' inputfile

---------- Post updated at 02:26 AM ---------- Previous update was at 02:19 AM ----------

Code:
perl -pe 's/,/\n/g' inputfile

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Selecting tables

Hi, Can anyone help me that, How to see the table fields in Oracle database through shell script(ksh). I have tried with the following: sqlplus -s $user/$passwd@$sid << SQL >> session.log select * from Testtab.sql I'm not able to see anything.. Thanks (4 Replies)
Discussion started by: zxcjggu708
4 Replies

2. Shell Programming and Scripting

selecting certain files

Hi, I have been working on a punch of codes and I got to a problem I hope to get help on. I have some files that I want to work with but the folder has other files in it. For example: The folder contains these files: path to files: /home/distribution/ ls: b.10; b.11; b.12; b.20; b.222;... (2 Replies)
Discussion started by: iconig
2 Replies

3. Shell Programming and Scripting

Selecting data between [ and ]

Hi Team, I am searching through log file using grep -i '<search_key>' <file_name>|awk '{print $18}' example outputs are I would like to select the data between and no other as I am getting some junk characters sometimes which chaging the o/p display format. Kindly assist.... (8 Replies)
Discussion started by: sanjaydubey2006
8 Replies

4. Shell Programming and Scripting

Selecting lines of a file

Say I wanted to select the 5th line of a file without knowing the context of the file. Would I use grep and pipe it into wc or is there a more simple way of doing this? (3 Replies)
Discussion started by: puttster
3 Replies

5. Shell Programming and Scripting

about selecting lines

Hello , i got text file like that' C:\Users\Public\Pictures\Sample Pictures\aa.jpg C:\Users\Public\Pictures\Sample Pictures\thumb.jpg C:\Users\Public\Pictures\vv\cc.jpg C:\Users\Public\Pictures\Sample Pictures\ee.jpg C:\Users\Public\aa\Sample Pictures\cvswsr.jpg... (1 Reply)
Discussion started by: davidkhan
1 Replies

6. UNIX for Dummies Questions & Answers

Help selecting some rows with awk

Hi there, I have a text file with several colums separated by "|;#" I need to search the file extracting all columns starting with the value of "1" or "2" saving in a separate file just the first 7 columns of each row maching the criteria, with replacement of the saparators in the nearly created... (2 Replies)
Discussion started by: capnino
2 Replies

7. Shell Programming and Scripting

selecting column in perl

Dear all, I have a rather large file of numbers which i would like to read into a script and then do some maths on a specific column( e.g column). so far i have been using the following awk command awk '{print $4}' infile.txt > out.tmp to strip out the desired column within the in perl... (3 Replies)
Discussion started by: Mish_99
3 Replies

8. Shell Programming and Scripting

Selecting a string

Hi, I have a small question... Since i am new to Unix ksh scripting i am having this problem of understanding... Well the thing is that i just want a part of a line for example Data Set=ELIG_Member_20090126.dat Count Total= 8192 Actual Total= 8187 I just want the value of Actual Total... (4 Replies)
Discussion started by: bhagya2340
4 Replies

9. Shell Programming and Scripting

Selecting one file from a list

Hi, I am able to do this by brute force but I am just curious if there is a better way of handling things. Basically the scenario is something like this: There are a number of files in a directory: rib.20071224.1759.gz 24-Dec-2007 17:59 132K rib.20071224.1959.gz 24-Dec-2007... (7 Replies)
Discussion started by: Legend986
7 Replies

10. Shell Programming and Scripting

Selecting a line value

Hello, I just wanted to know if there is a way in UNIX to select a line value from a list of words. there is no line number before each word, hence could not use grep. (4 Replies)
Discussion started by: unibboy
4 Replies
Login or Register to Ask a Question