Help with awking


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help with awking
# 1  
Old 02-24-2009
Help with awking

Hi...
How does awk or sed or even grep extract the following string out of my text file?.
'"${ETL_VW_SCHEMA}"'.IATA_STN_TZ_UTC_LCL_CONV_CV
'"${ETL_VW_SCHEMA}"'.CO
'"${ETL_VW_SCHEMA}"'.TEST_CO

I just need to extract the second entry which means I need to let awk know I am just searching for CO and not any combinations(like TEST_CO and IATA_STN_TZ_UTC_LCL_CONV_CV) and with the occurence of ETL_VW_SCHEMA...so, basically I need to search for '"${ETL_VW_SCHEMA}"'.CO
For some reason my awk doesn't recognize the period(.) in my search pattern.

Thx !
# 2  
Old 02-24-2009
Code:
$ nawk '/'"${ETL_VW_SCHEMA}"'.TEST_CO/' myFile.txt
'"${ETL_VW_SCHEMA}"'.TEST_CO
$ egrep ''"${ETL_VW_SCHEMA}"'.TEST_CO' myFile.txt
'"${ETL_VW_SCHEMA}"'.TEST_CO

# 3  
Old 02-24-2009
Thanks for the reply !
I am on Solaris and these commands quite not working as expected.

Code:
bash-2.03$ egrep ''"${ETL_VW_SCHEMA}"'.CO' my.dat
'"${ETL_VW_SCHEMA}"'.IATA_STN_TZ_UTC_LCL_CONV_CV
'"${ETL_VW_SCHEMA}"'.CO
'"${ETL_VW_SCHEMA}"'.TEST_CO

Code:
bash-2.03$ nawk '/'"${ETL_VW_SCHEMA}"'.CO/' my.dat
'"${ETL_VW_SCHEMA}"'.IATA_STN_TZ_UTC_LCL_CONV_CV
'"${ETL_VW_SCHEMA}"'.CO
'"${ETL_VW_SCHEMA}"'.TEST_CO

I get all the occurences !
# 4  
Old 02-24-2009
Escaping the period works.

Code:
awk '/\.\CO/' my.dat
'"${ETL_VW_SCHEMA}"'.CO

# 5  
Old 02-24-2009
you probably want this:
Code:
awk '/[.]CO$/' my.dat
'"${ETL_VW_SCHEMA}"'.CO

# 6  
Old 02-24-2009
Thx this works !
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Awking binary data

i have a binary data that has some text in it. what i want to do is, i want to grab just piece of information from the binary. but when i run my awk on it, it returns nothing. awk -F"MYINFO=" '{print $2}' mybinary however, when i install gawk, then try again, it works. i would prefer... (1 Reply)
Discussion started by: SkySmart
1 Replies

2. Shell Programming and Scripting

Awking custom output

i have data that can look like this: echo "Master_Item_Service_is_down=0_njava_lang_NoClassDefFoundError=0_njava_lang_OutOfMemoryError=1_nemxCommonAppInitialization__Error_while_initializing=0_nINFO__Stopping_Coyote_HTTP_1_1_on_http_8080=7_nThe_file_or_directory_is_corrupted_and_unreadable=0_n" ... (7 Replies)
Discussion started by: SkySmart
7 Replies

3. Shell Programming and Scripting

Grepping or awking multiple lines in a file - regex

data.txt: hellohellohello mellomello1mello tellotellotellotello bellobellowbellow vellow My attempts: egrep ".*mello1\n.*bellow" data.txt awk '/.*mello1.*\nbellow/' data.txt how can i search for patterns that are on different lines using simple egrep or awk? i only want the... (7 Replies)
Discussion started by: SkySmart
7 Replies

4. Shell Programming and Scripting

Awking string only 6 character long and providing a count

Morning Guys, I am attempting to awk a file which strings in the file is only 6 characters long and not more. Currently it is counting every line and giving a count of 59, but it should be 57 (not including the long baracode - 004705CIM*****) " awk '/./ {cnt++} END {print cnt}'... (11 Replies)
Discussion started by: Junes
11 Replies

5. Shell Programming and Scripting

Help awking a 'head -1 file.txt' input

Hi there, my ksh script collects a procstack trace for a particular pid and then greps it by a transaction id to find out the pthread ID: ---------- tid# 1876087 (pthread ID: 4466) ---------- So the pthread ID I want is 4466 in this case, and it is assighed to the variable $pthread.... (4 Replies)
Discussion started by: tmf33uk
4 Replies

6. Shell Programming and Scripting

awking two columns based on symbols

The input file has 3 columns. the first column with low values second with bigger.If the symbol is - in third column the numbers have to change the least in column1 and highest in col2. Input col1 col2 col3 1 2 + 2 3 - 3 4 + 5 6 - Output col1 col2 col3 1 2 + 3 2 - 3 4 + 6 5 - The... (2 Replies)
Discussion started by: stateperl
2 Replies

7. Shell Programming and Scripting

awking two columns

Hey ppl I have two columns with random values. i need to insert the 1st row of the first column with the highest number of the two rows in the first column and vice versa. some thing like this. I'm sorry If my question is unclear...:rolleyes: input col1 col2 12...11 11...14 34...45... (11 Replies)
Discussion started by: sophiesophie
11 Replies

8. Shell Programming and Scripting

Awking

Could someone find out wht exactly is goin wrong in the following awk: awk '/${EDW_DB_SCHEMA}.WRKR/ || !/otable/&&/${EDW_DB_SCHEMA}.WRKR/ || !/db-ter-load-data/&&/${EDW_DB_SCHEMA}.WRKR/' <my_graph>.ksh Basically, I am trying to achieve: Find out the occurence of WRKR table in <my_graph>.ksh... (3 Replies)
Discussion started by: anduzzi
3 Replies

9. Shell Programming and Scripting

awking and grepping parts of files: the 'super diff'

OKAY---- Here's what I must do. I have two files. I need to compare the two files such as with the diff command. I am adding FILENEW to FILEOLD If fields $1, $2, $5, and 6 are the same, then I don't want to add FILENEW records to FILEOLD. If they are not, then append the lines. Is... (11 Replies)
Discussion started by: jeffpas
11 Replies

10. Shell Programming and Scripting

Awking!! Printing decimal output is struck

Hi friends, I have a small problem with AWK. I am not able to print decimal values! :confused: below is my code: #! /bin/awk -f awk BEGIN{printf("%d",123)}; -> This prints the integer properly. x=111 awk BEGIN{printf("%d",x)}; -> This doesnt print! :( Please help me solve this. It... (4 Replies)
Discussion started by: divzz
4 Replies
Login or Register to Ask a Question