Thanks for the reply. But after using the above if block i still got error.
I saw in debug mode the fileCount value as mentioned below:
the if condition is unable to match as below:
PLease provide your inputs/suggestion on the above
Hi Arun,
If you can't (or don't want to) correct your input source, you could try one of the following:
When a.txt contains a <carriage-return> as well as a <newline> as shown by this output from from the command:
then running the above script with the argument 22454750 produces the output:
As you can tell from the script, I usually use the Korn shell; but this script will work with any POSIX conforming shell (including both ksh and bash).
As shamrock said, when you're comparing arithmetic values -le must be used instead of <= and -ge must be used instead of >=. With inequality, it doesn't make much difference whether you use != or -ne although -ne is preferred if you are comparing numbers. For equality, the form of test command determines the operator to use when you're comparing strings:
Hello Friends,
Can somebody assist an issue I am having? I have a separate file with a list of account ids
XXX200B02Y01
XXX200B03Y01
XXX200B05Y01
XXX200B07Y01
XXX200B08Y01
I call the file, and run an egrep against a directory and logfiles
AccountID=$(cat... (2 Replies)
I am trying to output all lines in a file where $7 is less than 30. The below code does create a result file, but with all lines in the original file. The original file is tab deliminated is that the problem? Thank you :).
awk 'BEGIN{FS=OFS=","} $7 < 30 {print}' file.txt > result.txt... (3 Replies)
I am trying to go through a file that has a few million lines. I want to only pull lines that contain a number anywhere in the ninth field, but it has to be after a "/" character. Here is my awk:
awk -F\| '$9 ~ /\/*{1,}*/ {print $0}' file1 > file2
However, it is just printing out every... (3 Replies)
Hi,
I have a problem when doing calculations in awk.
I want to add up a few numbers and output the result.
testfile:
48844322.87
7500.00
10577415.87
3601951.41
586877.64
1947813.89
$ awk '{x=x+$1};END{print x}' testfile
6.55659e+07The problem is the number format. It should show... (3 Replies)
Can someone explain whats happening here:
$ awk 'BEGIN {print (2.5 - 1)}'
1,5
2.5 - 1 is correctly calculated to 1,5 (using european locale)
$ echo "2.5" | awk '{temp = $1 - 1; print temp}'
1
If i now pipe the string 2.5 through awk it seems at it truncates 2.5 to 2?
What's the... (4 Replies)
Hi guys,
I am new to unix shell scripts. I have a file-A.txt which contained several names in "ABCo12345678.gz_to_ABCn12345678.gz" format. I want to extract the numbers in a "for" loop that means I can not use cut -c6-13 A.txt.Dose anyone know how to do it by using awk? Thank you so much.
... (4 Replies)
Hello,
I'm new to using AWK and would be grateful for some basic advice to get me started.
I have a file consisting of 10 fields. Initially I wish to calculate the number of . , ~ and ^ characters in the 9th field ($9) of each line. This particular string also contains alphabetical... (6 Replies)
I have a file with the following content.
> cat /tmp/internetusage.txt
6709.296322 30000 2/7/2010 0.00I am using the following awk command to calculate a percentage from field 1 and 2 from the file.
awk '{ print $1/$2*100 }' /tmp/internetusage.txt
This outputs the value "22.3643" as a... (1 Reply)
Hi!
I am writing a script handling downloading list of files and I have to check whether file is present locally and if not finished than continue downloading. To do so I have to compare sizes of remote file and local file.
To check remote file size I have to parse something like this:
... (2 Replies)