Pattern count for numeric values in aix


 
Thread Tools Search this Thread
Operating Systems AIX Pattern count for numeric values in aix
# 1  
Old 05-14-2012
Pattern count for numeric values in aix

Hi All ,

I have a small code that checks pattern of digits entered in unix mode .

Code:
$ echo 201202 | wc -c
7                            /* output*/

When i run same command in AIX 5.1 , i am getting output with some initial blanks

Code:
$ echo 201202 | wc -c
7                     /*  blanks and output*/

What command should i use to get output without any spaces in AIX
.Please help.


Moderator's Comments:
Mod Comment Use code tags, see your PMs for an explanation, thanks.

Last edited by zaxxon; 05-15-2012 at 06:47 PM.. Reason: code tags
# 2  
Old 05-14-2012
Keeping the newline:
Code:
$ echo 201202 | awk '{ printf("%s\n", $1)' | wc -c

-trb
# 3  
Old 05-14-2012
Hi ,

Above pasted code also return output after some gap .

Code:
$ echo 201202 | awk '{ printf("%s\n", $1)}' | wc -c
        7

When i send post , output 7 actually reside at the beginning .
Infact it does have spaces before value is displayed .

If u run this example in AIX and UNIX servers you can feel the difference .

Kindly share -- for this request

Last edited by zaxxon; 05-15-2012 at 06:47 PM..
# 4  
Old 05-14-2012
Opps, my bad... I put the "awk" before the "wc -c" instead of after it:

Code:
echo 201202 | wc -c | awk '{ printf("%-s\n", $1)}'

Here is an example of running it on AIX:

Code:
echo 201202 | wc -c | awk '{ printf("%-s\n", $1)}'                             
7

# 5  
Old 05-15-2012
Hi trb..

Thanks and it works fn
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Replace a numeric values in a certain column

Hi All, I am trying to replace a certain value from one place in a file . In the below file at position 35 I will have 8 I need to modify all 8 in that position to 7 I tried awk '{gsub("8","7",$35)}1' infile > outfile ----> not working sed -i 's/8/7'g' infile --- it is replacing all... (3 Replies)
Discussion started by: arunkumar_mca
3 Replies

2. UNIX for Dummies Questions & Answers

Script to Count the Numeric Values and get the Total

Can anyone help me in this? Here is the Secenario. I need to count the Numerical vaues from the below output Item processed: 1401 Item processed: 2839 Item processed: 1261 Item processed: 2584 Item processed: 2 Item processed: 988 Item processed: 1 Item processed: 2119 ... (3 Replies)
Discussion started by: Padmanabhan
3 Replies

3. Shell Programming and Scripting

Assigning numeric values to variable

I have a code like this v_num=9 comp_num=39 if then echo "pass" fi echo "end" I am getting an error ksh: v_num=99 comp_num=39 if then echo "pass" fi echo "end" (3 Replies)
Discussion started by: swayam123
3 Replies

4. UNIX for Dummies Questions & Answers

Only print lines with 3 numeric values

Hey guys & gals, I am hoping for some advice on a sed or awk command that will allow to only print lines from a file that contain 3 numeric values. From previous searches here I saw that ygemici used the sed command to remove lines containing more than 3 numeric values ; however how... (3 Replies)
Discussion started by: TAPE
3 Replies

5. Shell Programming and Scripting

Count occurences of a numeric string falling in a range

Dear all, I have numerous dat files (1.dat, 2.dat...) containing 500 numeric values each. I would like to count them, based on their range and obtain a histogram or a counter. INPUT: 1.dat 1.3 2.16 0.34 ...... 2.dat 1.54 0.94 3.13 ..... ... (3 Replies)
Discussion started by: chen.xiao.po
3 Replies

6. Shell Programming and Scripting

Count the alpha numeric

Hi all. This is one of my interview question. input : apple output : a - 1 p - 2 l - 1 e - 1 i written the code like this echo "apple" | fold -w1 | sort | uniq -c | awk '{print $2 "-->" $1}' is any other way to do ? (5 Replies)
Discussion started by: itkamaraj
5 Replies

7. Shell Programming and Scripting

How to check if the file contains only numeric values

How to check if the file contains only numeric values. I don't want to read entire file it eats lot of cpu Or any way which consumes less memory n cpu.. Please suggest -S (2 Replies)
Discussion started by: sunilmenhdiratt
2 Replies

8. Programming

numeric values ending in 'U'

I am getting back on the C++ programming after many years away. I recently received an SDK that has code like this where numeric values end in 'U'. What does this mean? if ((ptr % 16U) == 0U) return buffer; (3 Replies)
Discussion started by: sneakyimp
3 Replies

9. Shell Programming and Scripting

Remove non numeric values from a variable

Hello all, I am working on a basic script but need a little help. Issue: I am running a SQL Query using sqlplus and a shell script. I have the output of the statement stored as variable $A. $A is set to "other text here 45678754 other text here". I need to strip all text except that numeric... (13 Replies)
Discussion started by: ownedthawte
13 Replies

10. Shell Programming and Scripting

Replace spaces with 0's having numeric values.

What could be the regular expression with gsub function in awk to replace all numerics having spaces before to be replaced with 0s? (1 Reply)
Discussion started by: videsh77
1 Replies
Login or Register to Ask a Question