Sponsored Content
Top Forums Shell Programming and Scripting awk with multiple character delimiter Post 302499753 by popawu on Friday 25th of February 2011 10:20:27 AM
Old 02-25-2011
awk with multiple character delimiter

Hi all,

I'm trying to split fields separated by multiple characters :

Here's the string :
Code:
"toto"||"ta|ta"||"titi"

Here's what I want :
Code:
"toto"||"ta|ta"

I tried several ways, but it seems that my delimiter || is not working :

Code:
echo "\"toto\"||\"ta|ta\"||\"titi\"" | awk 'BEGIN {FS="[||]+";}{print $1"||"$2}'

"toto"||"ta

It works when there's no | in field two :

Code:
echo "\"toto\"||\"tata\"||\"titi\"" | awk 'BEGIN {FS="[||]+";}{print $1"||"$2}'

"toto"||"tata"

I don't understand why only one | is considered as a delimiter as I specified a double |...
Any help will be much appreciated !

Mat

Last edited by radoulov; 02-25-2011 at 11:37 AM.. Reason: Code tags, please!
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

How can I use double character delimiter in the cut command

Hi All, Can the cut command have double character delimiter? If yes, how can we use it. if my data file contains : apple || mango || grapes i used cut -f1 -d"||" filename but got an error. Plz help.... Thanks. (1 Reply)
Discussion started by: AshishK
1 Replies

2. UNIX for Dummies Questions & Answers

multi character delimiter

Hi All I have to encrypt files and add a suffix ".gpg_<key used>" to it For example if the file name is test.dat after encryption the file name will be test.dat.gpg_X005 (here X005 is the key). I want to decrypt the file later using that key and the original file name.both of them... (7 Replies)
Discussion started by: dr46014
7 Replies

3. 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

4. Shell Programming and Scripting

Replace multiple occurances of same character with a single character.

Hi all, Greetings, I have the following scenario, The contents of main file are like : Unix|||||forum|||||||||||||||is||||||the||best so||||||be|||||on||||||||||||||||||||||||||||||||||||||||||||it And i need the output in the following form: Unix=forum=is=the=best so=be=on=it ... (3 Replies)
Discussion started by: dipanchandra
3 Replies

5. 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

6. 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

7. Shell Programming and Scripting

Cutting a string using more than one character as delimiter

Hi , I have a set of files in a folder which i need to cut in to two parts.... Sample files touch AE_JUNFOR_2014_MTD_2013-05-30-03-30-02.TXT touch AE_JUNFOR_2014_YTD_2013-05-30-03-30-02.TXT touch temp_AE_JUNFOR_2014_MTD_2013-05-30-03-30-02.TXT touch... (4 Replies)
Discussion started by: chillblue
4 Replies

8. UNIX for Dummies Questions & Answers

How to replace particular occurrence of character in between a delimiter?

Hi, Hi, I have a file with following format 1|" "text " around " |" fire "guest"|" " 2| "xyz"" | "no guest"|"3" 3| """ test3""| "one" guest"|"4" My requirement is to replace all occurrences of " to ' which are occurring between |" "|delimiter so my output should look like this 1|"... (3 Replies)
Discussion started by: H_bansal
3 Replies

9. UNIX for Dummies Questions & Answers

How to use multiple delimiter?

How to split 2:6..5 in to separate columns (7 Replies)
Discussion started by: Nadela
7 Replies

10. Shell Programming and Scripting

sed searches a character string for a specified delimiter character, and returns a leading or traili

Hi, Anyone can help using SED searches a character string for a specified delimiter character, and returns a leading or trailing space/blank. Text file : "1"|"ExternalClassDEA519CF5"|"Art1" "2"|"ExternalClass563EA516C"|"Art3" "3"|"ExternalClass305ED16B8"|"Art9" ... ... ... (2 Replies)
Discussion started by: fspalero
2 Replies
MDBTools(1)															       MDBTools(1)

NAME
mdb-tables - Get listing of tables in an MDB database SYNOPSIS
mdb-tables [-S] [-1 | -d delimiter] database DESCRIPTION
mdb-tables is a utility program distributed with MDB Tools. It produces a list of tables contained within an MDB database in a format suitable for use in shell scripts. OPTIONS
-S Show system tables. System tables are generally those beginning with 'MSys' -1 specifies that the tables should be listed 1 per line. -d delimiter specifies an alternative delimiter. If no delimiter is specified, table names will be delimited by a tab character, or by newline if the -1 option was specified. NOTES
ENVIRONMENT
MDB_JET3_CHARSET Defines the charset of the input JET3 (access 97) file. Default is CP1252. See iconv(1). MDBICONV Defines the output charset. Default is UTF-8. mdbtools must have been compiled with iconv. MDBOPTS semi-column separated list of options: o use_index o no_memo o debug_like o debug_write o debug_usage o debug_ole o debug_row o debug_props o debug_all is a shortcut for all debug_* options HISTORY
mdb-tables first appeared in MDB Tools 0.3. SEE ALSO
gmdb2(1) mdb-export(1) mdb-hexdump(1) mdb-prop(1) mdb-sql(1) mdb-ver(1) mdb-array(1) mdb-header(1) mdb-parsecsv(1) mdb-schema(1) AUTHORS
The mdb-tables utility was written by Brian Bruns. BUGS
Access allows for tables to have spaces embeded in the table name. You must specify a delimiter (-d) if you intend on piping the output of mdb-tables to a program such as awk or cut. 0.7 13 July 2013 MDBTools(1)
All times are GMT -4. The time now is 09:03 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy