Sponsored Content
Top Forums Shell Programming and Scripting Replace spaces with 0's having numeric values. Post 69477 by Ygor on Friday 15th of April 2005 01:22:41 AM
Old 04-15-2005
I don't think you could use gsub() because you don't know the size of the replacement string. Perhaps use match() , e.g...
Code:
  BEGIN {z = "000000000000000000000"}
  {
    while(match($0, / +[0-9]/))
      $0 = substr($0,1,RSTART-1) substr(z,1,RLENGTH-1) substr($0,RSTART+RLENGTH-1)
    print
  }

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

stripping out non-numeric values in a list

hi all, i'm very new to scripting and have the folllowing issue. I have used a few commands to get a list of numbers, but I need to strip away the non-numeric ones, and then need a total of all values. any ideas? root@unixserver # cat myfile | awk '{print $8}'| sort -rn 1504 1344 896 704... (2 Replies)
Discussion started by: badoshi
2 Replies

2. 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

3. 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

4. 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

5. Shell Programming and Scripting

how to grep only particular length of numeric values

hi i have two types of file 1. temp.0000000001.data (10 digit numeric) 2. temp.000000001.data (9 digit numeric) i want to search a file which is having 10 digit numeric in between the file name. i use command like this.. ls | grep temp.^*.data but this will give both the files as... (2 Replies)
Discussion started by: somi2yoga
2 Replies

6. UNIX for Dummies Questions & Answers

Find and Replace random numeric value with non-numeric value

Can someone tell me how to change the first column in a very large 17k line file from a random 10 digit numeric value to a non numeric value. The format of lines in the file is: 1702938475,SNU022,201004 the first 10 numbers always begin with 170 (6 Replies)
Discussion started by: Bahf1s
6 Replies

7. 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

8. Shell Programming and Scripting

How to get a numeric value from Oracle to UNIX variable without spaces?

Hi, I am using the below code to get a numeric value from oracle to unix variable: BD_RC_CNT=`sqlplus -s ${WMD_DM_CONNECT} <<EOF set heading off set pagesize 0 Select count(*) from wmd_bad_data where proc_id = ${PROC_ID} and file_id = ${FILE_ID} and file_dt =... (7 Replies)
Discussion started by: Arun Mishra
7 Replies

9. UNIX for Advanced & Expert Users

Sort by second column numeric values

From googling and reading man pages I figured out this sorts the first column by numeric values. sort -g -k 1,1 Why does the -n option not work? The man pages were a bit confusing. And what if I want to sort the second column numerically? I haven't been able to figure that out. The file... (7 Replies)
Discussion started by: cokedude
7 Replies

10. 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
STRRCHR(3)								 1								STRRCHR(3)

strrchr - Find the last occurrence of a character in a string

SYNOPSIS
string strrchr (string $haystack, mixed $needle) DESCRIPTION
This function returns the portion of $haystack which starts at the last occurrence of $needle and goes until the end of $haystack. PARAMETERS
o $haystack - The string to search in o $needle - If $needle contains more than one character, only the first is used. This behavior is different from that of strstr(3). If $needle is not a string, it is converted to an integer and applied as the ordinal value of a character. RETURN VALUES
This function returns the portion of string, or FALSE if $needle is not found. CHANGELOG
+--------+------------------------------------+ |Version | | | | | | | Description | | | | +--------+------------------------------------+ | 4.3.0 | | | | | | | This function is now binary safe. | | | | +--------+------------------------------------+ EXAMPLES
Example #1 strrchr(3) example <?php // get last directory in $PATH $dir = substr(strrchr($PATH, ":"), 1); // get everything after last newline $text = "Line 1 Line 2 Line 3"; $last = substr(strrchr($text, 10), 1 ); ?> NOTES
Note This function is binary-safe. SEE ALSO
strstr(3), strrpos(3). PHP Documentation Group STRRCHR(3)
All times are GMT -4. The time now is 08:08 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy