I apologize, I had assumed FILENAME was something I could change. I went back through what you suggested before, kept FILENAME, fixed the sub string and everything displayed exactly how I wanted it.
---------- Post updated at 02:38 AM ---------- Previous update was at 02:37 AM ----------
Just wanted to do a follow up since I'm at work and have had more time to play with this.
This script awk '/JUNOS/ && /boot/ {sub (/[^\/]* .$/, "", FILENAME); print FILENAME $5}' *cpe.domain.net/show.version got me started on what the boss wanted me to do.
Output:
From there, I had to change the way this prints so that it shows column 5 of show.version first, followed by a space, then the device name. After that, the boss wanted me to sort by the software version. Lastly, that script above left in some output I wasn't too fond of, particularly in showing /show.version at the end of each device name, so I had to cut that out. Below is the modified script meeting all the requirements, along with a sample of the output.
Thanks again, RudiC! I definitely like the awk approach instead of the one I initially posted. Maybe I can get the boss on board with doing it that way too.
You seem a bit undecided if the trailing / should appear in your device string or not after getting rid of the file name. The sub (...) is there for exactly that - remove the show.version part, so your cut should be unnecessary. Obviously, the sub doesn't do what it is expected to. I guess that due to the space that you introduced which was not present in my original proposal. Playing around a bit with the regex in sub might bring you to where you want to be. You could also substitute the exact string : sub ("show.version", "", FILENAME).
I'm somewhat surprised of the key that you use in sort...
You seem a bit undecided if the trailing / should appear in your device string or not after getting rid of the file name. The sub (...) is there for exactly that - remove the show.version part, so your cut should be unnecessary. Obviously, the sub doesn't do what it is expected to. I guess that due to the space that you introduced which was not present in my original proposal. Playing around a bit with the regex in sub might bring you to where you want to be. You could also substitute the exact string : sub ("show.version", "", FILENAME).
I'm somewhat surprised of the key that you use in sort...
I definitely don't need the /show.version to appear. It doesn't hurt anything, I just prefer not to see it.
I don't fully understand what's going on in {sub (/[^\/]* .$/, "", FILENAME), so I don't get how to modify it to do what I want.
I used sort -k5 because the boss needed the list sorted by the software version, so we can easily see which devices need upgraded. If there's a way to do that with sub as well, I'd love to learn how to make that happen.
Also, I've moved on to turning this script into a function called cpever. The problem I'm running into is that I need to be able to run it from anywhere, and I now need to cut out a bunch of stuff before the actual device name and the /show.version at the end.
I need to make /home/clmbn-eng2/a/rwalker/svn/nw_config_data/ and /show.version disappear so my output can go back to looking like this [10.0R4.7] device1-r0.cpe.domain.net
Using the default field separator, there's just two fields in your file, so why use -k5 for sorting?
As you don't show the directory structure, and seem to keep changing targets, I'd suggest to play around with the sub regexes until it fits what you need. Also, I still don't understand why you keep the space in the regex making it pointless.
For your function, why don't you cd into the correct directory at the beginning?
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)