Sponsored Content
Top Forums Shell Programming and Scripting awk to find number in a field then print the line and the number Post 302951026 by RudiC on Friday 31st of July 2015 12:34:25 PM
Old 07-31-2015
Try also
Code:
awk -F\| '{$7=$3; $8=""; gsub(/^[^0-9]*|[^0-9]*$/, "",$7)} $7' OFS=\| file
1|net|ABC Letr1|1530|||1|
1|net|EXP_1040 ABC|1121|||1040|
1|net|EXP_TG1224|1122|||1224|
1|net|RExp 123 456 X|1234|||123 456|

This User Gave Thanks to RudiC For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

use awk to aggregrate the field number

Hi, I have a various files;each filled with hundreds of line with similar number of fields. I would like to extract out field $5 from each of this file and aggregate them before printing out to a file. I tried to :- #!/usr/bin/awk -f file="file1.txt file2.txt file3.txt file4.txt" ... (1 Reply)
Discussion started by: ahjiefreak
1 Replies

2. Shell Programming and Scripting

fourth field is number in a line

hi i hav a file like 121212 asdd d 7 dfsdffdffsdfsdfsdfdf rrretrtrtre 121212 asdd d 5 dfsdffdffsdfsdfsdfdf rrretrtrtre 121212 asdd d 5 dfsdffdffsdfsdfsdfdf rrretrtrtre 121212 asdd d 4 dfsdffdffsdfsdfsdfdf rrretrtrtre 121212 asdd d 6 dfsdffdffsdfsdfsdfdf rrretrtrtre i need to... (4 Replies)
Discussion started by: Satyak
4 Replies

3. Shell Programming and Scripting

awk to print exact field number

Hello there. I want some help with awk I have this script that reads a file from awk and you can insert from keyboard any list from the fields that exist so to be printed on monitor echo "give a choice" read -a ans array=${ans} awk -F: -v k="$array" '{ ... (4 Replies)
Discussion started by: covis
4 Replies

4. Shell Programming and Scripting

awk script: print line number n of another file

Hi, I wrote an awk script to analyse file A. I call the script with files A and B. File A has lines like: 000000033100001 000000036100001 000000039100001 The first 9 characters are interpreted as a line number; for each line number found I want to output this line number of file B. ... (13 Replies)
Discussion started by: kpg
13 Replies

5. Shell Programming and Scripting

find the field number

######################## SOLVED ################## Hi I have a header file like the following and the field "IDENTIFIER" can be at any possition on this line, The line can containt a variable number of field, not alway the same depending of the header file i use ... (6 Replies)
Discussion started by: kykyboss023
6 Replies

6. Programming

Find and print number after string in C

I'm trying find and print a number after a specific user passed string in each line of a text file using C (as requested by the powers that be). I've pieced together enough to read the file, find the string and print the line it was found on but I’m not sure where to even start in terms of finding... (3 Replies)
Discussion started by: cgol
3 Replies

7. Shell Programming and Scripting

find string nth occurrence in file and print line number

Hi I have requirement to find nth occurrence in a file and capture data from with in lines (between lines) Data in File. <QUOTE> <SESSION> <ATTRIBUTE NAME='Parameter Filename' VALUE='file1.parm'/> <ATTRIBUTE NAME='Service Name' VALUE='None'/> </SESSION> <SESSION> <ATTRIBUTE... (6 Replies)
Discussion started by: tmalik79
6 Replies

8. Shell Programming and Scripting

AWK print number of records, divide this number

I would like to print the number of records of 2 files, and divide the two numbers awk '{print NR}' file1 > output1 awk '{print NR}' file2 > output2 paste output1 output2 > output awl '{print $1/$2}' output > output_2 is there a faster way? (8 Replies)
Discussion started by: programmerc
8 Replies

9. Shell Programming and Scripting

Replace a field with line number in file

I am working on a script to convert bank data to a csv file. I have the format done - columns etc. The final piece of the puzzle is to change the second field (after the R) of every line to reflect its' line number in the file. I am stumped. I can use awk on each line but need help looping through... (9 Replies)
Discussion started by: Melah Gindi
9 Replies

10. Shell Programming and Scripting

Match pattern and print the line number of occurence using awk

Hi, I have a simple problem but i guess stupid enough to figure it out. i have thousands rows of data. and i need to find match patterns of two columns and print the number of rows. for example: inputfile abd abp 123 abc abc 325 ndc ndc 451 mjk lkj... (3 Replies)
Discussion started by: redse171
3 Replies
BBRETEST-NET.SH(1)					      General Commands Manual						BBRETEST-NET.SH(1)

NAME
bbretest-net.sh - Xymon network re-test tool SYNOPSIS
bbretest-net.sh DESCRIPTION
bbretest-net.sh is an extension script for Xymon that runs on the network test server. It picks up the failing network tests executed by the bbtest-net(1) program, and repeats these tests with a faster test cycle than the normal bbtest-net schedule. This means that when the server recovers and the network service becomes available again, this is detected quicker resulting in less reported downtime. Only tests whose first failure occurred within 30 minutes are included in the tests that are run by bbretest-net.sh. The 30 minute limit is there to avoid hosts that are down for longer periods of time to bog down bbretest-net.sh. You can change this limit with the "--fre- quenttestlimit=SECONDS" when you run bbtest-net. INSTALLATION
This script runs by default from your hobbitlaunch.cfg(5) file. FILES
$BBTMP/TESTNAME.LOCATION.status Temporary status file managed by bbtest-net with status of tests that have currently failed. $BBTMP/frequenttests.LOCATION Temporary file managed by bbtest-net with the hostnames that bbretest-net.sh should test. SEE ALSO
bbtest-net(1), xymon(7), hobbitlaunch.cfg(5) Xymon Version 4.2.3: 4 Feb 2009 BBRETEST-NET.SH(1)
All times are GMT -4. The time now is 07:42 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy