02-07-2015
Quote:
Originally Posted by
SkySmart
i will take heed of your warning.
if the pattern is not found, i'm totally ok with the code not showing anything at all.
btw, the log format is in the typical syslog format.
I'm glad that you're OK with the code not showing anything. Unfortunately, if your pattern is not found that code prints the entire file backwards and then prints an empty line.
So why is a file in the typical syslog format named
mail.log?
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I have an awk statement that works but I am calling awk twice and I know there has to be a way to combine the two statements into one. The purpose is to pull out just the ip address from loopback1.
cat config.txt | nawk 'BEGIN {FS="\n"}{RS="!"}{if ( $0 ~ "interface loopback1" ) print$4}' | nawk... (5 Replies)
Discussion started by: numele
5 Replies
2. Shell Programming and Scripting
Using these 2 comands to concatenate both outputs into single file:
cat testdata | awk 'BEGIN { FS="\n"; RS=""; } /<pattern1>/ {print}' > testdata1
cat testdata| awk '/<pattern2>/,EOF' >> testdata1
is it possible to combine both "awk" into 1-liner?
pls advise and thanks in advance. (5 Replies)
Discussion started by: ux4me
5 Replies
3. Shell Programming and Scripting
Hi Everyone,
awk 'BEGIN{print strftime("%c",1272814948)}' | tr -d '\n'
how to change tr -d '\n' to be part of the awk? means awk this pchoh time, and awk also remove '\n', instead of using "|" to combine "tr" command.
Thanks (2 Replies)
Discussion started by: jimmy_y
2 Replies
4. Shell Programming and Scripting
I'm rather new to programming, and am attempting to combine lines from 2 files in a way that is way beyond my expertise - any help would be appreciated!
I need to take a file (file1) and add columns to it from another file (file2). However, a line from file2 should only be added to a given line... (3 Replies)
Discussion started by: Cheri
3 Replies
5. UNIX for Dummies Questions & Answers
Hi,
I have the following two awk statements which I'd like to consolidate into one by piping the output from the first into the second awk statement (rather than having to write kat.txt out to a file and then reading back in).
awk 'BEGIN {FS=OFS=" "} {printf("%s ", $2);for (x=7; x<=10;... (3 Replies)
Discussion started by: kasan0
3 Replies
6. Shell Programming and Scripting
Hi, everyone!
I have two files, I want to combine them as follows:
File1
AAAA 23 45
AAAB 44 56
AAAC 34 65
AAAD 34 87
File2
AAAA 34 54
AAAE 34 56
Combined file
AAAA 23 45 34 54
AAAB 44 56
AAAC 34 65
AAAD 34 87
AAAE 34 56 (13 Replies)
Discussion started by: xshang
13 Replies
7. Shell Programming and Scripting
I have a file of 100,000 entries that look like:
chr1 980547 980667 +
chr1:980547-980667
chr1 980728 980848 +
chr1:980728-980848
chr1 980793 980913 +
chr1:980793-980913
I am trying to reformat them to into 5 columns that are tab delineated:
chr1 980547 980667 + ... (3 Replies)
Discussion started by: cmccabe
3 Replies
8. Shell Programming and Scripting
Hi folks,
I have a scenario to convert the update statements into insert statements using shell script (awk, sed...) or in database using regex.
I have a bunch of update statements with all columns in a file which I need to convert into insert statements.
UPDATE TABLE_A SET COL1=1 WHERE... (0 Replies)
Discussion started by: dev123
0 Replies
9. Shell Programming and Scripting
my code:
gawk 'NR>'"${LASTLINENUM}"' && NR<='"${LINEENDNUM}"'' ${LOGFILE} | gawk '{l=$0;} /'"${STRING1}"'/ && /'"${STRING2}"'/ {for (i=NR-'"${BEFOREGLAF}"'; i<=NR+'"${AFTERGLAF}"'; i++) o=i; t++;} END { for(i=1; i<=NR; i++) if (o) print l; print t+=0;}'
i would like to combine this into one... (5 Replies)
Discussion started by: SkySmart
5 Replies
10. UNIX for Beginners Questions & Answers
Hi, Below command is working as expected, but would like to know how to club the two AWK scripts in the command into one
echo -e "MMS000101S0203430A|20180412E|\nMMB0001INVESTMENT||107-86193-01-03|\nMMB0001FUND||107-86193-04-01|\nMMC9991 " | awk -F'|' -v OFS=, '/^MMC9991/{print r"|"s,t; next}... (3 Replies)
Discussion started by: JSKOBS
3 Replies