Below is my pattern:
While running without gsub it is fine
Retruns 13 column value with double quotes which represents no of errors occured which I want to get rid of. So using gsub but it is returning me strange behavior(sometime 1 , sometime 2)
Later I want to extend the implementation to if condition
BR,
PD
Last edited by Don Cragun; 11-27-2017 at 05:37 AM..
Reason: Change B tags to CODE tags.
In my case, there must be an way to save the manipulated string to a variable and treat later for comparison to numeric value.
I want to extract $13 column and compare it to numeric value something like
Please suggest since I tried with lot R&D I am not sure about the risk and might be other simple way to do it.
BR,
PD
Last edited by pradyumnajpn10; 11-27-2017 at 06:19 AM..
Below is my pattern:
While running without gsub it is fine
Retruns 13 column value with double quotes which represents no of errors occured which I want to get rid of. So using gsub but it is returning me strange behavior(sometime 1 , sometime 2)
Later I want to extend the implementation to if condition
BR,
PD
In addition to what MadeInGermany has already said, I'm confused by the "pattern" you've shown us above. I would guess that rather than that being a pattern, it is a sample of the data that might be in one of the files whose filename matches the pattern out*.csv. If that is the case, note that the three lines in your sample file contain 10, 11, and 10 fields, respectively, so field #13 on each line in that file is an empty string. So, the output from your script above (without the gsub()) for that output would be:
and the code with the gsub() would produce the output:
I assume that neither of these are really what you want as the output. Please explain more clearly what you are trying to do and show us the output you hope to get from the files you are processing.
This User Gave Thanks to Don Cragun For This Post:
Sorry to confuse.
Yes it is one line/pattern inside the out*.csv file.There may be many out*.csv files.
I am trying to search all the out*.csv files and if the 13 the column is equal to zero then Return success or else Print failure/exit.I am now trying something like below
I am not sure about the risk of doing like this. Please suggest if there is any simple way to do it. It should show the File name along with the status.
Ex:
out1.csv: failed
out2.csv: Pass
Second try:
BR,
PD
Last edited by pradyumnajpn10; 11-27-2017 at 06:57 AM..
I'm not sure what "risk" you expect. As is, the awk script will read only the files and output to screen. I don't think any damage can be done hereby.
There are, howsoever, some improvement opportunitites.
- terminate the find command by a + so only one single awk invocation occurs.
- if you need to preserve $13 for later processing (in the same script, that is), assign it to a variable first, and then operate on / from that.
- use the awkFILENAME variable for your desired output.
- use awk's printf statement to output to the same line.
This is my ubuntu version:
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 16.04.4 LTS
Release: 16.04
Codename: xenial
$ /bin/awk -V | head -n1
bash: /bin/awk: No such file or directory
I have gotten a script that helps me to parse,... (14 Replies)
Following one line of awk code removes first 3 characters from each line but when I run the same code on another linux platform it doesn't work and only prints blank lines for each record. Can anyone please explain why this doesn't work? (31 Replies)
Dear all,
I had script which used to work, but recently it is not working as expected.
I have command line in my shell script to choose the following format from the output_elog and perform some task afterwards on
As you see, I want all numbers in foramt following RED mark except for... (12 Replies)
Hi,
I have prepared a script and trying to execute it but not getting expected output. Could you please help and advise what is going wrong.
"If else" part in below script is not working basically.
I am running it on HP-UX.
for i in slpd puma sfmdb
do
echo "******\t$i\t*******"
echo... (10 Replies)
I have a number of files that I pass through awk/gsub.
I believe to have found a working regex and on 'test bed' sites it matches, however within gsub it does not.
Examples:
Initial data:
/Volumes/Daniel/Public/Drop Box/_Hellsing_Ultimate_OVA_-_10_.mkv
gsub & regex:
gsub("\]+\]",""
... (4 Replies)
Hi!
Been working on a script and I've been having a problem. I've finally narrowed it down to this variable I'm setting:
servername=$(awk -v FS=\/ '{ print $7 } blah.txt | sed 's\/./-/g' | awk -v FS=\- '{print $1}')"
This will essentially pare down a line like this:
... (7 Replies)
I am facing some strange problem.
I know, there is only one record in a file 'test.txt' which starts with 'X'
I ensure that with following command,
awk /^X/ test.txt | wc -l
This gives me output = '1'.
Now I take out this record out of the file, as follows :
awk /^X/ test.txt >... (1 Reply)
Hello.
Consider the following magic words:
# ls `which adduser`
ls: /usr/sbin/adduser: No such file or directory
#
Hmmm...
Then:
# ls /usr/sbin/adduser
/usr/sbin/adduser
#
Now what?
Unforunately this little sniippet is used in my debian woody server's mysql pre install script.... (2 Replies)