How do you expect people to propose a reasonable solution to a broken specification like above, supplying absolutely vital info only reluctantly bit by bit when explicitly asked?
Anyway, try (assuming a recent bash shell) EDIT: I'm pretty sure the sed part can be incorporated into the awk script but was just fed up with the problem...
sorry for my initial lack of information. i thought what i'd provided in my original post would be enough. i was wrong. I apologize.
thank you for your solution. seems like that'd be good enough. i'm hoping it'll be portable so that i am able to use it across platforms
awk - only solution:
May not work with awk versions that don't allow for a multi-char field separator.
The standards require that all conforming versions of awk accept an extended regular expression (ERE) for the input field separator (AKA the awk FS variable) and for the 3rd parameter to split() (when it is supplied). Some versions of awk also allow the record separator (the RS variable) to be an ERE, but the standards only specify the behavior when RS is a single character. I don't know of any 1980's or later version of awk that doesn't support an ERE for FS.
On a Solaris/SunOS system, you'll have to use /usr/xpg4/bin/awk or nawk instead of awk.
But, <<< redirections are not specified by the standards and will be treated as a syntax error by many shells. If you want to try RudiC's suggestion on a shell that doesn't support <<<, you could change the last line of the script to:
Or, you could change the 1st and last lines of the awk script to:
and:
respectively.
now, i have to search for a pattern within a particular time frame which the user will provide in the following format:
19/Jun/2018:07:04,21/Jun/2018:21:30
it is easy to get tempted to attempt this search with a variation of the following awk command:
awk... (3 Replies)
I need to vlookup and check the server not found.
Source file 1
server1
server2
server3
server4
server5_root
server6_silver
server7
server7-test
server7-temp
Source file 2
server1_bronze (6 Replies)
so my output is this:
session_closed=157
session_opened=151
session_closed=18
session_opened=17
there are two patterns here, but with different values. the two patterns are "session_opened" and "session_closed". i expect there will be many more other patterns.
what i want to do is... (8 Replies)
Can this awk statement be optimized? i ask because log.txt is a giant file with several hundred thousands of lines of records.
myscript.sh:
while read line
do
searchterm="${1}"
datecurr=$(date +%s)
file=$(awk 'BEGIN{split(ARGV,var,",");print var}' $line)
... (3 Replies)
I have two files like this:
fileA.net
A
B
C
fileA.dat
1
2
3
and I want the output
output_expected
A 1
B 2
C 3
I know that the easier way is to do a paste fileA.net fileA.dat, but the problem is that I have 10,000 couple of files (fileB.net with fileB.dat; fileC.net with... (3 Replies)
I have a list of id;
for example: file 1
dfghd
dfghe
dfgey
dfgeu
I have another data file that contain this ids as headers;
for ex. file2
>dfghd
gfdgfddl;klfkld;ld;lgl;dld'l'dv
>dfghe
gkwhjhsgdjdjdjhjddj
>dfgey
jdkjfhdjhfdkjhfdkhkdk
I wanted to compare file 1 and file 2... (1 Reply)
I have a log file that for some reason, once or two time a month, line foods are missing.
This log is generated from vmstat everyminute. I dont know why sometimes it does this.
Each line in the log should have 18 columns separated by one or more spaces.
Good Log: (not actual log)
1 1... (8 Replies)
Dear all
How to write the shell script for the following statement:
(C programming)
for (i=0;i<30;i++) {
if i=1
continue *skip this number
(To do function here....)
...
}
similar statement in while loop....
I wrote the script in sh... (3 Replies)