LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 06-09-2012, 11:42 AM   #1
nuser
LQ Newbie
 
Registered: Jun 2012
Distribution: open suse 12.2
Posts: 17

Rep: Reputation: Disabled
using regular shell variable inside awk


After many experiments, I need help!Please tell me how to work the following example..
Code:
var=$(cat t.log|awk '!/</'|tail -1) 
cat t.log|awk '/$var/,0'
awk not see $var!Why? And most important how to do it?

The main task is a list of url addresses (equal) to remove those whose port is serial
examle:
Code:
http://ex.com:101
http://ex.com:105
http://ex.com:103
http://ex.com:11 #for remove
http://ex.com:12 #
http://ex.com:13 #
http://ex.com:14 #
 
Old 06-10-2012, 07:38 AM   #2
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
single quotes (AKA "hard quotes") protect everything from the shell. If you use double quotes, then the variable expansion will work.
 
  


Reply



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



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to using regular shell variable inside awk nuser Linux - General 1 06-10-2012 06:35 AM
[SOLVED] awk: how can I assign value to a shell variable inside awk? quanba Programming 6 03-23-2010 02:18 AM
shell command using awk fields inside awk one71 Programming 6 06-26-2008 04:11 PM
Using Shell variable inside the C program Varsha_vdd Linux - Newbie 5 06-17-2008 09:42 AM
How to acess Variable defined in perl script inside an awk call sumin Programming 3 04-26-2007 05:19 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 09:44 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration