Records which are staring with double quote(") and a number


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Records which are staring with double quote(") and a number
# 1  
Old 08-04-2009
Records which are staring with double quote(") and a number

Hi Experts...

I am trying to find out separting the records which are staring with double quote(") and a six digit number(ex: 012456,987654,etc) from a file.

For example :

Source File :

Code:
 
"116462","SMITH CHEVR
"164098","SIMPS
"104498","SIMPSONVIL

"Export lments"
"Copyrts rerved."
"Cion - Dxyabcfdse"

output file should look like

Code:
"116462","SMITH CHEVR
"164498","SIMPS
"164498","SIMPSONVIL

Can you please help...

Thankyou!
# 2  
Old 08-04-2009
Quote:
Originally Posted by vsairam
...
the records which are staring with double quote(") and a six digit number(ex: 012456,987654,etc) from a file.
...
Should this record be matched as well ?

Code:
"12345678","TEST"

It starts with a double quote followed by six digits, and hence it satisfies the conditions you posted.

In other words, must there be a double quote character at the 8th position ?

tyler_durden
# 3  
Old 08-04-2009
tyler_durden...

It contains a double quote (") at 8th position.
# 4  
Old 08-04-2009
Code:
$ 
$ cat data.txt
"116462","SMITH CHEVR
"164098","SIMPS
"104498","SIMPSONVIL
"Export lments"
"Copyrts rerved."
"Cion - Dxyabcfdse"
"1234567","TEST"
$ 
$ perl -ne 'print if /"\d{6}"/' data.txt
"116462","SMITH CHEVR
"164098","SIMPS
"104498","SIMPSONVIL
$

tyler_durden
# 5  
Old 08-05-2009
Quote:
Originally Posted by vsairam
I am trying to find out separating the records which are staring with double quote(") and a six digit number(
Code:
egrep "^\"[0-9]{6}\"" file

Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Extract delta records using with "comm" and "sort" commands combination

Hi All, I have 2 pipe delimited files viz., file_old and file_new. I'm trying to compare these 2 files, and extract all the different rows between them into a new_file. comm -3 < sort file_old < sort file_new > new_file I am getting the below error: -ksh: sort: cannot open But if I do... (7 Replies)
Discussion started by: njny
7 Replies

2. Shell Programming and Scripting

Replacing all but the first and last double quote in a line with a single quote with awk

From: 1,2,3,4,5,This is a test 6,7,8,9,0,"This, is a test" 1,9,2,8,3,"This is a ""test""" 4,7,3,1,8,"""" To: 1,2,3,4,5,This is a test 6,7,8,9,0,"This; is a test" 1,9,2,8,3,"This is a ''test''" 4,7,3,1,8,"''"Is there an easy syntax I'm overlooking? There will always be an odd number... (5 Replies)
Discussion started by: Michael Stora
5 Replies

3. Shell Programming and Scripting

Replacing Double Quote in Double Quote incsv file

Hi All , We have source data file as csv file and since data could contain commas ,each attribute is quoted into double quotes.However problem is that some of the attributa data also contain double quotes which is converted to double double quote while creating csv file XLs data : ... (2 Replies)
Discussion started by: Shalini Badal
2 Replies

4. Shell Programming and Scripting

Replace double quotes with a single quote within a double quoted string

Hi Froum. I have tried in vain to find a solution for this problem - I'm trying to replace any double quotes within a quoted string with a single quote, leaving everything else as is. I have the following data: Before: ... (32 Replies)
Discussion started by: pchang
32 Replies

5. Shell Programming and Scripting

awk sub function "quote or slash"

I struggle to understand why its used slash / instead of doublequotes " in sub function of awk. This is taken from the manual of awksub(/USA/, "United States", "the USA and Canada") But this work alsosub("USA", "United States", "the USA and Canada") Is there any reason of why to select one... (2 Replies)
Discussion started by: Jotne
2 Replies

6. Shell Programming and Scripting

Compare two files with different number of records and output only the Extra records from file1

Hi Freinds , I have 2 files . File 1 |nag|HYd|1|Che |esw|Gun|2|hyd |pra|bhe|3|hyd |omu|hei|4|bnsj |uer|oeri|5|uery File 2 |nag|HYd|1|Che |esw|Gun|2|hyd |uer|oi|3|uery output : (9 Replies)
Discussion started by: i150371485
9 Replies

7. Shell Programming and Scripting

Regex in grep to match all lines ending with a double quote (") OR a single quote (')

Hi, I've been trying to write a regex to use in egrep (in a shell script) that'll fetch the names of all the files that match a particular pattern. I expect to match the following line in a file: Name = "abc" The regex I'm using to match the same is: egrep -l '(^) *= *" ** *"$' /PATH_TO_SEARCH... (6 Replies)
Discussion started by: NanJ
6 Replies

8. Shell Programming and Scripting

Extracting the records which contains atleast one double quote(")

Hi Experts, I have a file with some of records contain double quotes ("). I need to write these records in separate file and have to delete the same records from the original file. For Example: Orginal File : 100000,abcd,CRED,MO 100001,"efgh",CRED 100002,ijkl,CRED,TX... (3 Replies)
Discussion started by: vsairam
3 Replies

9. Shell Programming and Scripting

double-quote inside double-quote

hey all, i made a simple .sh like this: echo "<style media="screen" type="text/css">@import url("main.css");</style>" but the output is: <style media=screen type=text/css>@import url(main.css);</style> i want to keep double-quotes, can anyone help me? thanks (3 Replies)
Discussion started by: indraf
3 Replies
Login or Register to Ask a Question