I've been trying to find the answer to this with Google and trying to browse the forums, but I haven't been able to come up with anything. If this has already been answered, please link me to the thread as I can't find it.
I've been asked to write a script that pulls a list of our CPE then have the script dig through the show.version file to pull a specific entry from there and display it all on one line.
This is the code I've come up with, but the display is all wrong. Note: I am no programmer/scripter, this is something new I'm learning for a recent promotion.
Code:
for CPE_DEVICE in `ls -d *cpe.domain.net`; do; echo $CPE_DEVICE; grep JUNOS $CPE_DEVICE/show.version | grep boot | awk '{print $5}'; done
It's not that easy for us to tell what output comes from where. Did you try to stop echo from printing a <newline> char? On some systems (you fail to mention yours), this can be done with the -n option. Or, use printf with an adequate format string.
Please be aware that your entire pipe could probably be replaced by one single awk command.
It's not that easy for us to tell what output comes from where. Did you try to stop echo from printing a <newline> char? On some systems (you fail to mention yours), this can be done with the -n option. Or, use printf with an adequate format string.
Please be aware that your entire pipe could probably be replaced by one single awk command.
Programming in ZSH, everything we use is based on FreeBSD.
This line gives me all my CPE in a list just fine.
Code:
for CPE_DEVICE in `ls -d *cpe.domain.net`; do; echo $CPE_DEVICE;
This half is supposed to pull the version running for each CPE and display that next to the CPE name.
I tried echo -n but it still gives me the output wrong. It puts a lot of the devices and their software version on the same line, but I still get lines where multiple devices show together on one line with one software version.
The output comes out like this with echo -n added.
When I ran what you tried with the proper information filled (filename, domain) in I get this.
Code:
awk: extra ] at source line 1
context is
/JUNOS/ && /boot/ {sub >>> (/[^/] <<<
awk: syntax error at source line 1
awk: illegal statement at source line 1
extra ]
The directory I'm running this in has a directory for each CPE device. So this script here pulls a list of all the devices and puts them in a nice neat list for me, no problems.
Code:
for CPE_DEVICE in `ls -d *cpe.domain.net`; do; echo $CPE_DEVICE;
The later half of my code is supposed to pull the show.version information, but GREPing out the word boot and printing the 5th column which is the actual software version. It does do that, however the output isn't where it should be.
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)