Sponsored Content
Top Forums UNIX for Advanced & Expert Users Replacing string length based on pattern Post 302988191 by vgersh99 on Wednesday 21st of December 2016 03:41:20 PM
Old 12-21-2016
awk -F, '{for(i=1;i<=NF;i++) if ($i~/^P/) $i="P" substr($i,3)}1' OFS=, myFile
This User Gave Thanks to vgersh99 For This Post:
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

String spllittinf based on pattern

Hi, I have a sample.properties file and it contains the following content. today--RSS_URL=http://someurl i need to split the string and need the result in the folliwng form. x1=today x2=RSS_URL x3=http://someurl Your immediate response will be graetly appreciated (3 Replies)
Discussion started by: eswarreddya
3 Replies

2. Shell Programming and Scripting

Replacing one Char in a string of variable length

Hi all, I am trying to find the best way of making a change to 1 char in a string, the string can be between 1 and 14 characters. I am reading a line in from a file which contains 012341231231:2:102939283:NNN: Require :NBN: 012838238232:3:372932:NNN: Require :NNB: I need to change 1 N or a... (8 Replies)
Discussion started by: nkwilliams
8 Replies

3. Shell Programming and Scripting

Retrieve string from each line in a file based on a pattern in Unix

I have a file which contains several lines. Sample content of the file is as below. OK testmessage email<test@123> NOK receivemessage email<123@test> NOK receivemessage email(123@test123) NOK receivemessage email<abc@test> i would like to know by scripting will... (10 Replies)
Discussion started by: ramasar
10 Replies

4. Shell Programming and Scripting

Concatenating and appending string based on specific pattern match

Input #GEO-1-type-1-fwd-Initial 890 1519 OPKHIJEFVTEFVHIJEFVOPKHIJTOPKEFVHIJTEFVOPKOPKHIJHIJHIJTTOPKHIJHIJEFVEFVOPKHIJOPKHIJOPKEFVEFVOPKHIJHIJEFVHIJHIJEFVTHIJOPKOPKTEFVEFVEFVOPKHIJOPKOPKHIJTTEFVEFVTEFV #GEO-1-type-2-fwd-Terminal 1572 2030... (7 Replies)
Discussion started by: patrick87
7 Replies

5. Shell Programming and Scripting

help - sed - insert space between string of form XxxAxxBcx, without replacing the pattern

If the string is of the pattern XxxXyzAbc... The expected out put from sed has to be Xxx Xyz Abc ... eg: if the string is QcfEfQfs, then the expected output is Qcf Ef Efs. If i try to substitute the pattern with space then the sed will replace the character or pattern with space,... (1 Reply)
Discussion started by: frozensmilz
1 Replies

6. Shell Programming and Scripting

sed or awk command to replace a string pattern with another string based on position of this string

here is what i want to achieve... consider a file contains below contents. the file size is large about 60mb cat dump.sql INSERT INTO `table1` (`id`, `action`, `date`, `descrip`, `lastModified`) VALUES (1,'Change','2011-05-05 00:00:00','Account Updated','2012-02-10... (10 Replies)
Discussion started by: vivek d r
10 Replies

7. Shell Programming and Scripting

Sort a hash based on the string length of the values

Hi, I want to be able to sort/print a hash based on the string length of the values. For example %hash = ( key1 => 'jeri', key2 => 'corona', key3 => 'una, ); I want to be able to print in the following order (smallest to largest) una,jeri,corona OR... (1 Reply)
Discussion started by: jdilts
1 Replies

8. Shell Programming and Scripting

Add string based on character length

Good day, I am a newbie here and thanks for accepting me I have a task to modify input data where my input data looks like 123|34567|CHINE 1|23|INDIA 34512|21|USA 104|901|INDIASee that my input has two columns with different character length but max length is 5 and minimum length is 0 which... (1 Reply)
Discussion started by: fastlearner
1 Replies

9. Shell Programming and Scripting

awk to insert missing string based on pattern in file

Using the file below, which will always have the first indicated by the digit after the - and last id in it, indicated by the digit after the -, I am trying to use awk to print the missing line or lines in file following the pattern of the previous line. For example, in the file below the next... (4 Replies)
Discussion started by: cmccabe
4 Replies

10. Shell Programming and Scripting

Script to find string based on pattern and search for its corresponding rows in column

Experts, Need your support for this awk script. we have only one input file, all these column 1 and column 2 are in same file and have to do lookup for values in one file(column1 and column2) but output we need in another file Need to grep row whose string contains 9K from column 1. When found... (6 Replies)
Discussion started by: as7951
6 Replies
DIGITTOINT(3)						   BSD Library Functions Manual 					     DIGITTOINT(3)

NAME
digittoint, digittoint_l -- convert a numeric character to its integer value LIBRARY
Standard C Library (libc, -lc) SYNOPSIS
#include <ctype.h> int digittoint(int c); #include <xlocale.h> #include <ctype.h> int digittoint_l(int c, locale_t loc); DESCRIPTION
The digittoint() function converts a numeric character to its corresponding integer value. The character can be any decimal digit or hexa- decimal digit. With hexadecimal characters, the case of the values does not matter. While the digittoint() function uses the current locale, the digittoint_l() function may be passed a locale directly. See xlocale(3) for more information. RETURN VALUES
The digittoint() function always returns an integer from the range of 0 to 15. If the given character was not a digit as defined by isxdigit(3), the function will return 0. SEE ALSO
ctype(3), isdigit(3), isxdigit(3), xlocale(3) BSD
April 6, 2001 BSD
All times are GMT -4. The time now is 03:27 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy