No need to define X="*" if you don't need it. I proposed that because in the first version you wanted all three *cpes when $1 was empty. So - remove that and just print the error message.
Then, to be on the safe side, set X="" before the case, and execute the awk only if X is non-empty: [ $X ] && awk '...' ...
I thought I could get away with not defining X="*"but that was the first thing I tried and it fails. So, without X="*", I get every single device (including ones I didn't specify) sorted by software version. No error message.
Setting X=""before the caseand adding [ $X ] &&in front of my awkfixed it!
One task to go, and I hope I'm done with this. Just need to figure out how to do my -vto search for specific software versions matched against the first 5 characters of the version, skipping the first character [for the search, but still printing it
Example of what my awklooks at in show.version
JUNOS Base OS boot [12.3R7.7]
I'm honestly not sure how to even start this in my awk.
I'm assuming it requires another sub (...)but my brain is refusing to cooperate. I spent a good chunk of my night searching out the answer to the last problem before giving in to ask you for help, so I feel a little fried.
So how would you pass the -v (plus version info) to cver? Like cver -c -v 12.3R, i.e. second and third parameter? What error checking needs to be done?
Yeah, exactly like that. At minimum, they need to be able to search the first two digits and at max the whole thing. Searching only the first digit would be the equivalent of not using -v.
All software versions start with two digits, followed by a .
The place after .contains a single digit of 0-9
After that the next character is either R or S
After R or S it seems the next digit could be 0-9 or double digit like 11 followed by a . then a single digit 0-9
I don't want to limit any of the engineers from being able to search a full version, because I don't know how specific of a version someone might want to search for. I do know at minimum, they have to use -vfollowed by two digits.
If whatever they search for doesn't exist, a simple "No match found" message will suffice.
Ex:
Whatever they do search that exists shows everything up to what they searched and includes anything that may be after it.
Well, this is becoming more and more complicated, and more and more error checking would need to be done, like parameter count, value validation, etc. - which I neglect here, or leave it up to the reader, resp.
OK, run the awk like
This doesn't check for $2 to be -v, and if $3 is missing, field 5 in the file is just checked to start with the [ char.
Last edited by RudiC; 03-23-2016 at 08:30 AM..
Reason: typos, typos, and typos
cver -c -vruns the same as cver -c, but I'm ok with that. The engineers will figure out that won't work so well for them without an actual search term after -v. Ultimately, it would be cool if -vwas undefined by the user if it worked like my (*)where it does echo "Unrecognized or incomplete command.\nUse -h for help."but really, I'm not too worried about that.
cver -c -v 1prints a list of all versions with 1 in them, but not all of them oddly. I don't get all of version 10 or any results for 12 and 13. Searching any digit 0-9 (except 1) will return a list of any software version that has any of those numbers in it anywhere in the version.
cver -c -v 10doesn't print any software versions starting with 10. Instead, it printed a list of versions with 10 in it somewhere else.
Ex: [11.4R10.3] device-e0.cpe.domain.net
cver -c -v 11prints nothing. From the example above, I have devices with software version 11.
cver -c -v 12prints nothing. I have multiple devices software versions starting with 12.
cver -c -v 13prints nothing. I do have one device in -c with a 13. software version.
cver -e -v 14prints nothing. I do have one device in -e with a 14. software version.
---------- Post updated at 04:05 AM ---------- Previous update was at 01:07 AM ----------
I regret it doesn't work out that well for you. Unfortunately I could do only very basic testing without some serious test data, but it worked for me. Must be a awk version problem, probably with the escaping of the [ char. It's just that char that needs escaping. Try $5 ~ "^[[]" SRCH. It needs the ^ in front!
Sorry for missing the matching double quote.
Currently using below script but echo it print the output in two line.
Input file all-vm-final-2.txt
CEALA08893 SDDC_SCUN DS_SIO_Workload_SAPUI_UAT_01 4
CEALA09546 SDDC_SCUN DS-SIO-PD5_Workload_UAT_SP1_Flash_07 4
CEALA09702 SDDC_SCUN DS-VSAN-RMP-WORKLOAD01 4
DEALA08762 SDDC_LDC... (3 Replies)
Hello.
I have been looking high and low for the solution for this. I seems there should be a simple answer, but alas.
I have a big xml file, and I need to extract certain information from specific items. The information I need can be found between a specific set of tags. let's call them... (2 Replies)
Hi,
I have written this code
------------------------------------------------
# !/bin/ksh
i=0
while
do
j=$i
while
do
echo -e $j
#printf "%d",$j
j=`expr $j - 1`
done
echo
i=`expr $i + 1`
done
----------------------------------------------------
The ouput which... (2 Replies)
hey
i m kinda new to this so i will appreciate any help
, i have this list of values:
pwwn = 0x50012482009cd7a7 nwwn=0x50012482009cd7a6 port_id = 0x280200
pwwn = 0x5001248201bcd7a7 nwwn=0x5001248201bcd7a6 port_id = 0x280300
pwwn = 0x50012482009c51ad nwwn=0x50012482009c51ac port_id =... (4 Replies)
I'm having problems since few days ago, and i'm not able to make it works with a simple awk+grep script (or other way to do this).
For example, i have a input file1.txt:
cat inputfile1.txt
218299910417
1172051195
1172070231
1172073514
1183135117
1183135118
1183135119
1281440202
... (3 Replies)
Hi,
Need awk help to group and print lines to format the output as shown below
INPUT FORMAT
set echo on
set heading on
set spool on
/* SCHEMA1 */ CREATE TABLE T1;
/* SCHEMA1 */ CREATE TABLE T2;
/* SCHEMA1 */ CREATE TABLE T3;
/* SCHEMA1 */ CREATE TABLE T4;
/* SCHEMA1 */ CREATE TABLE T5;... (5 Replies)
I am performing a grep command and I need to know how to echo "NONE" or "0" to my file if grep does not find what i am looking for.
echo What i found >> My_File
grep "SOMETHING" >> My_File
I am sure this is easy, I am sort of new at this!
Thanks (2 Replies)