The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
what i do wrong, find grep rm, help me plz djdes22 Shell Programming and Scripting 4 04-28-2008 12:45 PM
what am i doing wrong jzocco Shell Programming and Scripting 1 05-25-2006 04:55 PM
Please tell me what do I do wrong here! bobo UNIX for Dummies Questions & Answers 4 02-20-2006 10:55 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-14-2007
manas_ranjan's Avatar
manas_ranjan manas_ranjan is offline
Registered User
  
 

Join Date: Jul 2007
Location: Amsterdam
Posts: 177
what is wrong in this awk or grep ....

hi champs,

i have a strange problem,
let ,
i have a array1, whose 1st character is ${array1[0]}=h

let i want to search test.txt by awk/grep where the 1st character is the ${array1[0]}....

if i am seraching by awk/grep by using variable..it return no rows from test.txt...
awk -v find=${array1[0]} '/^find.*/ {print $0}' test.txt
grep '^${array1[0]}.*' test.txt


but if i am doing it by following methods, strangely it gives me the xact o/p
grep '^h.*' test.txt
awk '/^h.*/ {print $0}' test.txt


any suggesttion , how to make my search dynamic.....or what is the problem in above awk/grep
  #2 (permalink)  
Old 11-14-2007
joydeep joydeep is offline
Registered User
  
 

Join Date: Nov 2007
Posts: 13
in grep, "^$" denotes the begaining and end of search string. whereas "^h.*" means any name start with "h". You could better understand if you use "grep '^$h.*' test.txt"
  #3 (permalink)  
Old 11-15-2007
manas_ranjan's Avatar
manas_ranjan manas_ranjan is offline
Registered User
  
 

Join Date: Jul 2007
Location: Amsterdam
Posts: 177
thankx a lot...but even if i tried this one...
grep '^\${array1[0]}.*' test.txt=> no use
but what is the problem in awk.......
awk -v find=${array1[0]} '/^find.*/ {print $0}' test.txt
any suggestions.....
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 01:51 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0