How to use multiple delimiter?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers How to use multiple delimiter?
# 1  
Old 10-11-2014
How to use multiple delimiter?

How to split 2:6..5 in to separate columns
# 2  
Old 10-11-2014
Quote:
Originally Posted by Nadela
How to split 2:6..5 in to separate columns
Welcome to forums,

Try

Code:
akshay@nio:~$ echo '2:6..5' | awk -F'[:.]' '{print $1,$2,$4}'
2 6 5

This User Gave Thanks to Akshay Hegde For This Post:
# 3  
Old 10-11-2014
Hi Akshay,

Thank you

But what if my data are in a file. echo 'file name' wont work right?
# 4  
Old 10-11-2014
Quote:
Originally Posted by Nadela
Hi Akshay,

Thank you

But what if my data are in a file. echo 'file name' wont work right?
No, try like this

Code:
awk -F'[:.]' '{print $1,$2,$4}' file

This User Gave Thanks to Akshay Hegde For This Post:
# 5  
Old 10-11-2014
it worked thank you

i also tired
Code:
echo "$(cat text.text)" | awk -F'[:.]' '{print $1,$2,$4}'.

.

Thank you

Last edited by Scrutinizer; 10-11-2014 at 02:02 PM.. Reason: code tags
# 6  
Old 10-11-2014
Quote:
Originally Posted by Nadela
it worked thank you

i also tired echo "$(cat text.text)" | awk -F'[:.]' '{print $1,$2,$4}'..

Thank you
Do not use echo and cat, save resources, and always try to make code as simple as possible just do like below

Code:
awk -F'[:.]' '{print $1,$2,$4}' file

I posted answer with echo in #2, since you didn't mention that you are going to handle file, it was just an example.

--
Please use codetags for data and code in future.
This User Gave Thanks to Akshay Hegde For This Post:
# 7  
Old 10-11-2014
thank you
 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Shell script to Split matrix file with delimiter into multiple files

I have a large semicolon delimited file with thousands of columns and many thousands of line. It looks like: ID1;ID2;ID3;ID4;A_1;B_1;C_1;A_2;B_2;C_2;A_3;B_3;C_3 AA;ax;ay;az;01;02;03;04;05;06;07;08;09 BB;bx;by;bz;03;05;33;44;15;26;27;08;09 I want to split this table in to multiple files: ... (1 Reply)
Discussion started by: trymega
1 Replies

2. Shell Programming and Scripting

Extract multiple columns base on double quotes as delimiter

Hi All, I have my data like below "1","abc,db","hac,aron","4","5" Now I need to extract 1,2,4th columns Output should be like "1",abc,db","4" Am trying to use cut command but not able to get the results. Thanks in advance. (4 Replies)
Discussion started by: weknowd
4 Replies

3. Shell Programming and Scripting

Break line content into multiple lines using delimiter

I need to break the line after every 3rd semi colon(;) using Unix shell scripting Input.txt ABC;DEF;JHY;LKU;QWE;BVF;RGHY; Output.txt ABC;DEF;JHY; LKU;QWE;BVF; RGHY; (1 Reply)
Discussion started by: meet_calramz
1 Replies

4. Shell Programming and Scripting

Perl Code to change file delimiter (passed as argument) to bar delimiter

Hi, Extremely new to Perl scripting, but need a quick fix without using TEXT::CSV I need to read in a file, pass any delimiter as an argument, and convert it to bar delimited on the output. In addition, enclose fields within double quotes in case of any embedded delimiters. Any help would... (2 Replies)
Discussion started by: JPB1977
2 Replies

5. Shell Programming and Scripting

Split file into multiple files using delimiter

Hi, I have a file which has many URLs delimited by space. Now i want them to move to separate files each one holding 10 URLs per file. http://3276.e-printphoto.co.uk/guardian http://abdera.apache.org/ http://abdera.apache.org/docs/api/index.html I have used the below code to arrange... (6 Replies)
Discussion started by: vel4ever
6 Replies

6. Shell Programming and Scripting

Pasting multiple files using awk with delimiter

hi, i want to PASTE two files, with a delimiter in between, using awk and pipe the output to another file. i am able to achive the reqirement using PASTE command. but it has a limitation of length till 511 bytes. Example: ------- File1: ---- sam micheal file2: ---- bosco... (11 Replies)
Discussion started by: mohammedsadath
11 Replies

7. Shell Programming and Scripting

awk with multiple character delimiter

Hi all, I'm trying to split fields separated by multiple characters : Here's the string : "toto"||"ta|ta"||"titi" Here's what I want : "toto"||"ta|ta" I tried several ways, but it seems that my delimiter || is not working : echo "\"toto\"||\"ta|ta\"||\"titi\"" | awk 'BEGIN... (4 Replies)
Discussion started by: popawu
4 Replies

8. Shell Programming and Scripting

php setcookie multiple values with delimiter

Hi all, setting a cookie multiple values with delimiter $value = 'TM=1276245099:LM=1276245099'; // etc etc setcookie('unix',"$value"); This generates %3ATM%3D1276245099%3ALM%3D1276245099 I want the data as it is TM=1276245099:LM=1276245099 Any suggestions? (0 Replies)
Discussion started by: ./hari.sh
0 Replies

9. Shell Programming and Scripting

Multiple characters including single quote in delimiter

Hello, I need to replace the comma to something else between the single quote: 1aaa,bbb,'cc,cc','ddd',1 2aaa,bbb,'ccc','d,d',0 to 1aaa,bbb,'cc<comma>cc','ddd',1 2aaa,bbb,'ccc','d<comma>d',0 Can someone help? Thanks. (2 Replies)
Discussion started by: bgirl
2 Replies
Login or Register to Ask a Question