Sponsored Content
Top Forums Shell Programming and Scripting Add NA When String is not found Post 303024071 by dis0wned on Friday 28th of September 2018 08:45:04 AM
Old 09-28-2018
I apologize, when I added the code I kept it to a minimum in an effort to keep it clearer.

Code:
awk '/-- show cdp neighbors detail --/,/- show diagnostic result module all detail --/' $tempdir/useful> $tempdir/shcdpnedet
awk '/Device ID:/ || /address:/ || /Interface:/ || /VLAN:/ || /Platform:/ || /Software/' $tempdir/shcdpnedet > $tempdir/newtt
tr -d '\015' < $tempdir/newtt > $tempdir/new
awk '/IP address/ { printf("%s\t", $0); next } 1' $tempdir/new> $tempdir/newt
awk '/Port ID / { printf("%s\t", $0); next } 1' $tempdir/newt > $tempdir/newt1
awk '/Native VLAN/ { printf("%s\t", $0); next } 1' $tempdir/newt1 > $tempdir/newt2
sed 's/Device/\n&/g' $tempdir/newt2  > $tempdir/newt3
awk '/Device ID:/ { printf("%s\t", $0); next } 1' $tempdir/newt3 > $tempdir/newt4
awk '/Platform:/ { printf("%s\t", $0); next } 1' $tempdir/newt4 > $tempdir/newt44
awk '/Software/ { printf("%s\t", $0); next } 1' $tempdir/newt44 > $tempdir/newt4

This is the code used to produce the output, I see the confusion with the additional fields in the desired output. If one of the input fields is not present, I would like to insert an NA
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Display only found string

Is there a way for grep to output only the found string and not the whole line? I have a ksh script which reads in a file and loops through every line looking up on a grep -f list. For it to only display only the string found i pass this to awk as a variable and loop through the list file using... (5 Replies)
Discussion started by: Cranie
5 Replies

2. Shell Programming and Scripting

Search for string and display those NOT found

In my script I read a input file and search all the files in a directory and it's sub-directories for that string using: find . -type f -print | xargs grep $var1 This just displays all the lines the string was found on. Too much data. What I need is to store in a file one time those... (17 Replies)
Discussion started by: John Rihn
17 Replies

3. Solaris

Can't install Unicode::String due to String.so not found

CPAN.pm: Going to build G/GA/GAAS/Unicode-String-2.09.tar.gz Checking if your kit is complete... Looks good Writing Makefile for Unicode::String cp String.pm blib/lib/Unicode/String.pm cp lib/Unicode/CharName.pm blib/lib/Unicode/CharName.pm /usr/bin/perl /usr/perl5/5.8.4/lib/ExtUtils/xsubpp... (5 Replies)
Discussion started by: PatrickBaer
5 Replies

4. Shell Programming and Scripting

Finding a string with another string is found

finding a string with another string is found EX: abs c/- i want to find /-, then copy abs. i know it's easy use awk, but my problem is the substr syntax. substr($2,2,2) will give me /- but the conflict is /- is not always the second characted of the second string. (11 Replies)
Discussion started by: engr.jay
11 Replies

5. Linux

Find String in FileName and move the String to new File if not found

Hi all, I have a question.. Here is my requirement..I have 500 files in a path say /a/b/c I have some numbers in a file which are comma seperated...and I wanted to check if the numbers are present in the FileName in the path /a/b/c..if the number is there in the file that is fine..but if... (1 Reply)
Discussion started by: us_pokiri
1 Replies

6. Shell Programming and Scripting

grep on string and printing line after until another string has been found

Hello Everyone, I just started scripting this week. I have no background in programming or scripting. I'm working on a script to grep for a variable in a log file Heres what the log file looks like. The x's are all random clutter xxxxxxxxxxxxxxxxxxxxx START: xxxxxxxxxxxx... (7 Replies)
Discussion started by: rxc23816
7 Replies

7. Shell Programming and Scripting

Grep a string and write a value to next line of found string

Hi, I have two variables x and y. i need to find a particular string in a file, a workflow name and then insert the values of x and y into the next lines of the workflow name. basically it is like as below wf_xxxxxx $$a= $$b= $$c= figo $$d=bentley i need to grep the 'wf_xxxx' and then... (6 Replies)
Discussion started by: angel12345
6 Replies

8. UNIX for Dummies Questions & Answers

Append a string on the next line after a pattern string is found

Right now, my code is: s/Secondary Ins./Secondary Ins.\ 1/g It's adding a 1 as soon as it finds Secondary Ins. Primary Ins.: MEDICARE B DMERC Secondary Ins. 1: CONTINENTAL LIFE INS What I really want to achieve is having a 1 added on the next line that contain "Secondary Ins." It... (4 Replies)
Discussion started by: newbeee
4 Replies

9. Shell Programming and Scripting

Modify a file by another file: add new line and variable after string is found

hello, I have problem with writing/adjusting a shell script. I searched forum and unfortunately couldn't write scipt based on the information I found. I never wtire such so it's hard for me and I do need to modify one script immediately. case looks like: 1. 'file' that needs to be modified... (3 Replies)
Discussion started by: bipbip
3 Replies

10. Shell Programming and Scripting

Get 20 lines above string found, and 35 below string

i want to search a log for a string. when that string is found, i want to grab the a set number of lines that came before the string, and a set number of lines that come after the string. so if i search for the word "Error" in the /var/log/messages file, how can I output the 20 lines that came... (4 Replies)
Discussion started by: SkySmart
4 Replies
TEXVC(1)							  [FIXME: manual]							  TEXVC(1)

NAME
texvc - math equation PNG renderer SYNOPSIS
texvc {tempdir} {outputdir} {texcode} {encoding} DESCRIPTION
texvc is designed to render math equations written in latex code into PNG images. OPTIONS
{tempdir} directory where temporary files are created. {outputdir} directory where the result image is stored. {texcode} latex code string representing math equations. {encoding} used encoding in latex code string. OUTPUT
Status codes and HTML/MathML transformations are returned on stdout. A rasterized PNG file will be written to the output directory, named for the MD5 hash code. texvc output format is like this: o +%5 ok, but not html or mathml o c%5%h ok, conservative html, no mathml o m%5%h ok, moderate html, no mathml o l%5%h ok, liberal html, no mathml o C%5%h%m ok, conservative html, with mathml o M%5%h%m ok, moderate html, with mathml o L%5%h%m ok, liberal html, with mathml o X%5%m ok, no html, with mathml o S syntax error o E lexing error o F%s unknown function %s o - other error with the following codes: o - null character o %5 - md5, 32 hex characters o %h - html code, without characters o %m - mathml code, without characters AUTHOR
This manual page was written by Marc Dequ[`e]nes (Duck) Duck@DuckCorp.org for the Debian(TM) system (but may be used by others). Permission is granted to copy, distribute and/or modify this document under the terms of the GNU General Public License, Version 2 any later version published by the Free Software Foundation. On Debian systems, the complete text of the GNU General Public License can be found in /usr/share/common-licenses/GPL. AUTHOR
Marc Dequ[`e]nes Author. COPYRIGHT
Copyright (C) 2003 Marc Dequenes (Duck) [FIXME: source] 2005-01-02 TEXVC(1)
All times are GMT -4. The time now is 05:35 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy