Sponsored Content
Top Forums Shell Programming and Scripting Using awk or grep with Variables in a script Post 302632847 by Scrutinizer on Tuesday 1st of May 2012 01:31:20 AM
Old 05-01-2012
Hi inifinitydon,

I do not understand 1) . There should be no sorting and the output order of gsh list_grad should be preserved

2) what error do you mean? numbers in the last that do not exist in the numbers file?. What do you want to do with those?

Code:
gsh list_gras | awk 'NR==FNR{numbers[$1];next} $NF in numbers' "$1" -

But call the script as:
Code:
./rac_huawei_script.sh huawei_bscs

About learning this stuff, I like this O'Reilly book:
sed & awk, 2nd Edition-O'Reilly Media

There is also a solid on-line tutorial:
Awk - A Tutorial and Introduction - by Bruce Barnett

Other ingredients are practice and hanging out on these forums Smilie
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

passing variables to awk from ksh script

I'm trying to write a ksh script that uses awk, but I want to pass variables to awk. For example (not working): if ];then searchstr=$1 lsof -i | awk '{if($9~/SEARCHSTR/) print $2} SEARCHSTR=$searchstr' else echo "usage: $0 <search string>" fi I tried several options. Is it... (3 Replies)
Discussion started by: rein
3 Replies

2. Shell Programming and Scripting

awk as grep with variables

i have such awk working fine but how to use variable instead of strings awk '/asdasd.*asda.*asdasd/' file2.txt This is not working: awk '/${a}.*${b}.*${c}/' file2.txt Thanks & regards Peter (7 Replies)
Discussion started by: pp56825
7 Replies

3. Shell Programming and Scripting

Execution problem with grep script (2 variables)

#!\bin\sh TEST=test.log GREP=\usr\bin\grep $GREP -i 'dog\|cat' ${TEST} Why doesn't grep run at all? (10 Replies)
Discussion started by: jazzaddict
10 Replies

4. Shell Programming and Scripting

awk (or other) script that assigns fields from a line to multiple variables

Hey all, Unfortunately I have only basic knowledge of awk and/or scripting. If I have a file with lines that can look similar to this: Name=line1 Arg1=valueA Arg2=valueB Arg3=valueC Name=line2 Arg1=valueD Name=line3 Arg1=valueE Arg3=valueF Name=line4 Arg2=valueG ... (4 Replies)
Discussion started by: Rike255
4 Replies

5. Shell Programming and Scripting

Script with awk and grep

Hi .. I am working on a shell script to do following task. I have Input file as follows. I have to find failed or Offline disk and run command # hic -ip 172.124.24.59 getlogicalgrp |grep -B10 diskid against the disk ID which is 1 line above the disk state. I am using grep with -b10 is because... (7 Replies)
Discussion started by: dynamax
7 Replies

6. Shell Programming and Scripting

Awk script problem - Variables Causing Issue

can someone please explain to me what i'm doing wrong with this code: WELT=$(awk '(($1 ~ "^${caag}$") || ($2 ~ "^${caag}$"))' /tmp/Compare.TEXT) when run from the command line, it works. but it seems to be having a problem doing the comparison when variables are involved. i tested from... (1 Reply)
Discussion started by: SkySmart
1 Replies

7. Shell Programming and Scripting

awk recieving script variables.

Hi, I have a script which recieves 3 variables. #!/bin/bash Directory=$1 Archive=$2 Log_File_Path=$3 ... ... ... gzip -l *.xml.gz |awk '{print $1"^"$2"^"$4}'|sed '$d' In awk instead of $1 which should be Compressed size its recieving Directory name. How should this be... (1 Reply)
Discussion started by: chetan.c
1 Replies

8. Shell Programming and Scripting

awk issue expanding variables in ksh script

Hi Guys, I have an issue with awk and variables. I have trawled the internet and forums but can't seem to get the exactt syntax I need. I have tried using awk -v and all sorts of variations but I have hit a brick wall. I have spent a full day on this and am just going round in circles. ... (3 Replies)
Discussion started by: gazza-o
3 Replies

9. UNIX for Dummies Questions & Answers

Use of Variables in a sed/awk script

Hi, After looking at the differents post on this forum, I am convinced that I will benefit from the experience of advanced Unix user on some script I have already done for an aeronautical study. Here is one of them : Step 1 : sed -e "s/??/00/g" Base_Awk.txt > Awk_Cut_00.txt4; sed... (11 Replies)
Discussion started by: Marc_Camoc
11 Replies

10. Shell Programming and Scripting

Sending awk variables into curl in a bash script

Hello experts! I have a file1 with the following format (yr,day, month, hour,minute): 201201132435 201202141210 201304132030 201410100110 ... What i want to do is to assign variables and then use them in the curl command to download the text of each event from a web page. What I have... (6 Replies)
Discussion started by: phaethon
6 Replies
FSVS - URL format(5)						       fsvs						      FSVS - URL format(5)

NAME
Format of URLs - FSVS can use more than one URL; the given URLs are overlaid according to their priority. FSVS can use more than one URL; the given URLs are overlaid according to their priority. For easier managing they get a name, and can optionally take a target revision. Such an extended URL has the form ['name:'{name},]['target:'{t-rev},]['prio:'{prio},]URL where URL is a standard URL known by subversion -- something like http://...., svn://... or svn+ssh://.... The arguments before the URL are optional and can be in any order; the URL must be last. Example: name:perl,prio:5,svn://... or, using abbreviations, N:perl,P:5,T:324,svn://... Please mind that the full syntax is in lower case, whereas the abbreviations are capitalized! Internally the : is looked for, and if the part before this character is a known keyword, it is used. As soon as we find an unknown keyword we treat it as an URL, ie. stop processing. The priority is in reverse numeric order - the lower the number, the higher the priority. (See url__current_has_precedence() ) Why a priority? When we have to overlay several URLs, we have to know which URL takes precedence - in case the same entry is in more than one. (Which is not recommended!) Why a name? We need a name, so that the user can say 'commit all outstanding changes to the repository at URL x', without having to remember the full URL. After all, this URL should already be known, as there's a list of URLs to update from. You should only use alphanumeric characters and the underscore here; or, in other words, w or [a-zA-Z0-9_]. (Whitespace, comma and semicolon get used as separators.) What can I do with the target revision? Using the target revision you can tell fsvs that it should use the given revision number as destination revision - so update would go there, but not further. Please note that the given revision number overrides the -r parameter; this sets the destination for all URLs. The default target is HEAD. Note: In subversion you can enter URL@revision - this syntax may be implemented in fsvs too. (But it has the problem, that as soon as you have a @ in the URL, you must give the target revision every time!) There's an additional internal number - why that? This internal number is not for use by the user. It is just used to have an unique identifier for an URL, without using the full string. On my system the package names are on average 12.3 characters long (1024 packages with 12629 bytes, including newline): COLUMNS=200 dpkg-query -l | cut -c5- | cut -f1 -d' ' | wc So if we store an id of the url instead of the name, we have approx. 4 bytes per entry (length of strings of numbers from 1 to 1024). Whereas using the needs name 12.3 characters, that's a difference of 8.3 per entry. Multiplied with 150 000 entries we get about 1MB difference in filesize of the dir-file. Not really small ... And using the whole URL would inflate that much more. Currently we use about 92 bytes per entry. So we'd (unnecessarily) increase the size by about 10%. That's why there's an url_t::internal_number. Author Generated automatically by Doxygen for fsvs from the source code. Version trunk:2424 11 Mar 2010 FSVS - URL format(5)
All times are GMT -4. The time now is 09:53 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy