problem while searching in a file by 'AWK'


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting problem while searching in a file by 'AWK'
# 1  
Old 05-01-2008
problem while searching in a file by 'AWK'

Hi ,

i am writing a script in which i am using following command to grep some string and then storing it's output to v, as like below :-
v=$(awk -F, '{ if ( $NF ~ /DEV/ ) print $0 "_BLD01";else print $0 "_RC01" }' mytest)

Here i am facing following issues:-

1. it is searcing DEV in the file, but i want to search DEV only if it has DEV at the end of any string. and in this case It is finding all the DEV words in the string.
for exp :- DEVinder.sh ( i want it will search only if there is DEV at the end like inder.sh_DEV) and ignore it has DEV oter than last.
# 2  
Old 05-02-2008
Code:
 awk  '/DEV$/{ print $0 "_BLD01"}
       !/DEV$/{print $0 "_RC01" }' mytest

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

Hsearch() problem when searching for strings.

I have written a code in C where the objective is to search for strings. There are two files: 1. Database file which has more than one billion entries. This file is read in argv in the C code below. The format of the file is like this: a.txt apple b.txt candle c.txt glue 2. There is another... (1 Reply)
Discussion started by: shoaibjameel123
1 Replies

2. Shell Programming and Scripting

Problem with the awk in searching the contents in a file

Hello all, I am a newbie in awk. I am struggling in this problem for a long.Actually I have two files, filea and fileb. File a is actually a search key through it I have to find the corresponding japanese tag from file b. filea contains the data like this: sm982882 sm1893548 sm2420025... (3 Replies)
Discussion started by: csim_mohan
3 Replies

3. Shell Programming and Scripting

searching a file with a specified text without using conventional file searching commands

without using conventional file searching commands like find etc, is it possible to locate a file if i just know that the file that i'm searching for contains a particular text like "Hello world" or something? (5 Replies)
Discussion started by: arindamlive
5 Replies

4. Shell Programming and Scripting

Problem with searching and then editing a file through shell.

Hi, I have searched through this forum as there are many similar entries but could'nt get one of them to work, either that or they were just different to what I needed. Basically I have a file, recordsDatabase. In this file are a few different fields. There is a unique identifier eg 001... (5 Replies)
Discussion started by: U_C_Dispatj
5 Replies

5. Shell Programming and Scripting

Searching a file using awk or sed

I want to search a file in a specific location and I don't want to use find command. I want to give the path also where the file is for searching it. Pls help (3 Replies)
Discussion started by: maitree
3 Replies

6. Shell Programming and Scripting

awk searching

hi all, Please can you help me with the awk searching where: I have a master file where I need the string $12. the string $ 12 varies between 3 and 4 characters and I need to bring only the characters ending in 68. try this, but is so bad my search i know awk-F, '(if... (8 Replies)
Discussion started by: manzi
8 Replies

7. Shell Programming and Scripting

Searching Problem

Hi, I would like produce follow console-printing if I searching a string (but for all hits): e.g.: Datei1HelloWorld Option -H is not possible on my unix. Thanks for help! ---------- Post updated at 02:36 AM ---------- Previous update was at 02:34 AM ---------- my actually... (9 Replies)
Discussion started by: Timmää
9 Replies

8. Shell Programming and Scripting

Searching word in a file with awk

Hello everyone! I use a script to query for installed packages with yum (I use RHEL 4 with yum installed) and the output is redirected to a file. My script scan this file to find a package and the version of it. The script works fine until I search for a package name with special characters.... (3 Replies)
Discussion started by: studieu
3 Replies

9. Shell Programming and Scripting

Reading an Input file and searching for occurrences WIHOUT SED or AWK

Hi people. I am new to shell scripting, so I need a little help. I want to create a script named that takes an argument as a file, Read the input file and look for occurrences of the current username (say abc.xyz) who is executing the script. On finding an occurrence of the username take that line... (2 Replies)
Discussion started by: kartikkumar84@g
2 Replies

10. Shell Programming and Scripting

PERL: Searching for a string in a text file problem

Looking for a bit of help. I need to search for a string of words, but unfortunately these words are located on separate lines. for example the text output is: United Chanmpions Ronaldo Liverpool Losers Torres and my script code is print("DEBUG - checking file message"); while... (15 Replies)
Discussion started by: meevagh
15 Replies
Login or Register to Ask a Question