Search Results

Search: Posts Made By: nes
2,430
Posted By Akshay Hegde
As RudiC said you have to use split function ...
As RudiC said you have to use split function

Here is example to start

$ bashArray=(10 20 30 4 50)

$ cat test.awk
BEGIN{
split(variable,awkArray);
for(i in awkArray)...
2,430
Posted By RudiC
You need to split the TempArr variable into an...
You need to split the TempArr variable into an awk Array, which then you can iterate through.
2,430
Posted By clx
TempArr is just a variable inside awk, its not an...
TempArr is just a variable inside awk, its not an array as you think and trying to iterate through for (i in arr) construct.

What does your $ID contains? May be you can get the array created...
2,466
Posted By SriniShoo
you need to wrap couple of statements in round...
you need to wrap couple of statements in round brackets with if
/usr/xpg4/bin/awk -v a="${THREADIDARR }" 'BEGIN {FS="|"; n=split(a,b," "); for(i=1; i<=n; i++) c[b[i]]=1;} length($3) == 0{if(ftag ==...
2,466
Posted By neutronscott
Definitely. Adding some whitespace to the...
Definitely. Adding some whitespace to the situation:


/usr/xpg4/bin/awk -v a="${THREADIDARR }" '
BEGIN {
FS="|"
n=split(a,b," ")
for(i=1; i<=n; i++)
c[b[i]]=1
}

length($3) == 0...
8,108
Posted By Don Cragun
The following seems pretty easy to me and doesn't...
The following seems pretty easy to me and doesn't need sort or uniq to get a list with no duplicates:
#!/bin/ksh
var=$(awk -F '( : )|[]]' '!($2 in a) {a[$2]; print $2}' Input)
printf 'var=%s\n'...
8,108
Posted By Don Cragun
I repeat: What are you going to do with this...
I repeat: What are you going to do with this variable with hundreds of thousands of values separated by vertical bars in it once you get it? Now that you've said you want to get rid of duplicates,...
8,108
Posted By rbatte1
You cannot usefully execute sort on a single...
You cannot usefully execute sort on a single record (i.e. your variable)$ var="1|2|4|3|5"
$ echo $var | sort
1|2|4|3|5
$You would need to put the sort in before building the variable up.

Have...
8,108
Posted By rbatte1
You can adjust it a little towards the end to...
You can adjust it a little towards the end to have:-:
:
:
done < /tmp/file1
text="${text%|}"
echo "$text"
:
:
This will trim off the trailing | if that is what is required.



Robin
8,108
Posted By wisecracker
Longhand using __builtins__ on OSX 10.7.5, ksh,...
Longhand using __builtins__ on OSX 10.7.5, ksh, default terminal.
#/bin/ksh
# get_vals.sh
ifs_str="$IFS"
IFS="$IFS"'[]'
echo "20140320 00:08:23.846 INFO [WebContainer : 84] - anything in line...
8,108
Posted By Don Cragun
No! Sort is used to sort lines into order. ...
No!
Sort is used to sort lines into order.
You requested that there be only one line of output, and the code samples that you have been given provide a single line of output as you requested; so...
8,108
Posted By SriniShoo
temp=$(grep "nk1577" $INPUTFILE | awk -F [\]\[]...
temp=$(grep "nk1577" $INPUTFILE | awk -F [\]\[] '{split($2, a, " : "); b[a[2]]++} END {for(x in b) {a[n++] = x+0}; asort(a); for(i = 1; i <= n; i++) {print a[i]}}' ORS='|')
8,108
Posted By SriniShoo
Can you please explain deleting duplicate entries...
Can you please explain deleting duplicate entries and sorting
How do you need the output
8,108
Posted By SriniShoo
temp=$( awk -F [\]\[] '{split($2, a, " : ");...
temp=$( awk -F [\]\[] '{split($2, a, " : "); print a[2]}' ORS='|' input_file)
8,108
Posted By rbatte1
Do you mean you want one long string or an array...
Do you mean you want one long string or an array where you can address each element?

A few more questions:-
How many records are we considering?
What operating system version and level?
What...
1,520
Posted By SriniShoo
That is not an error, just a warning
That is not an error, just a warning
Forum: Solaris 12-06-2013
2,280
Posted By MadeInGermany
Solaris mailx does not have -a option. But the...
Solaris mailx does not have -a option.
But the following seems to work
MAILFORMAT="Please do not replay this mail.This mail is auto generated."
FILENAME=file.csv

mailx -r autoreplay@gmail.com...
16,854
Posted By MadeInGermany
nawk ' /ERROR|WARNING/ {if (cnt==0) s=s...
nawk '
/ERROR|WARNING/ {if (cnt==0) s=s (s?RS:s) b; cnt=3}
cnt&&cnt-- {s=s RS $0}
/Starting/ {s=""; cnt=0}
{b=$0}
END {print s}
' errorlog
Forum: Solaris 12-06-2013
2,280
Posted By zozoo
it works for me fine in Solaris u can try...
it works for me fine in Solaris
u can try uuencode then pipe it to mail

---------- Post updated at 01:30 PM ---------- Previous update was at 12:40 PM ----------

u can try for other methods...
16,854
Posted By RudiC
Try also:tac file | awk '{T[NR%3]=$0}...
Try also:tac file | awk '{T[NR%3]=$0} /ERROR|WARNING/ {L=NR+1; print T[(NR+1)%3];print T[(NR+2)%3]; print; next} NR<=L; /Starting/ {exit}' |tac
line8
WARNING
line8.8
line8.9
line9
ERROR...
16,854
Posted By drl
Hi. Using part of Corona688's solution: ...
Hi.

Using part of Corona688's solution:
#!/usr/bin/env bash

# @(#) s2 Demonstrate extraction of lines before and after match.

if uname -a | grep -i solaris
then
echo " ( Note...
16,854
Posted By Corona688
Try: nawk '/Starting/ { N=0 } {L[++N]=$0 } END {...
Try: nawk '/Starting/ { N=0 } {L[++N]=$0 } END { for(X=1; (X<=N)&&(X <= 3); X++) print L[X] }' inputfile

It keeps a list of lines in the array L, and every time it encounters 'Started', resets...
Forum: Solaris 12-07-2006
123,719
Posted By Ygor
Try...nawk...
Try...nawk 'c-->0;$0~s{if(b)for(c=b+1;c>1;c--)print r[(NR-c+1)%b];print;c=a}b{r[NR%b]=$0}' b=2 a=4 s="string" file1...where "b" and "a" are the number of lines to print before and after string "s".
...
Showing results 1 to 23 of 23

 
All times are GMT -4. The time now is 01:45 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy