Sponsored Content
Top Forums UNIX for Beginners Questions & Answers File manipulation place 0 before the number using sed Post 303039601 by RudiC on Thursday 10th of October 2019 04:26:10 AM
Old 10-10-2019
In case there are other occurrences of three letters followed by a space and a digit, you might want to narrow down the search pattern to the locale months:
Code:
sed -r "s/($(locale abmon | tr ';' '|')) ([[:digit:]] )/\1 0\2/g" file

Be aware that you need sed to recognize / handle EREs for this simple tr approach.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

file name Manipulation using sed

Hi, I have a file name, for which I want to strip out the first bit and leave the rest... So I want to take the file name .lockfile-filename.10001 ,strip it and have only filename.10001 ... Thanking you all inadvance, Zak (6 Replies)
Discussion started by: Zak
6 Replies

2. Shell Programming and Scripting

Place number with awk

Hello, if I've a list of number 23 34 56 78 how I can place a sequence of ordinated number in a boundary column so 1 23 2 34 3 56 4 78 Thanks in advance! (3 Replies)
Discussion started by: cv313x
3 Replies

3. Shell Programming and Scripting

Read a number from file and place it back

Hi All, I want to read one number from the file. Only one number will be there in the file. then i have to increment the number in my script and put it back in the same file. Is it possible? Can anybody help me? Thanks, Vinay (6 Replies)
Discussion started by: vinayakatj56
6 Replies

4. Shell Programming and Scripting

File manipulation with AWK and SED

Hello How do i check that correct input files are used while using AWk and SED for file manipulation? e.g awk '/bin/ {print $0 }' shell.txt sed 's/hp/samsung/' printers.txt how do i ensure that the correct input files I am working with are used? (5 Replies)
Discussion started by: Pauline mugisha
5 Replies

5. Shell Programming and Scripting

SED/AWK file read & manipulation

I have large number of data files, close to 300 files, lets say all files are same kind and have extension .dat , each file have mulitple lines in it. There is a unique line in each file containing string 'SERVER'. Right after this line there is another line which contain a string 'DIGIT=0',... (4 Replies)
Discussion started by: sal_tx
4 Replies

6. Shell Programming and Scripting

setter and getter functions for file manipulation with sed

Hi, I would really appreciate some help, I couldn't nail my problem: I would like to create some setter and getter functions to make my life easier. my sample file contains: keyword - some tabs - value - semicolon number 12.1; float .3; double 12; real 12.2324; stuff .234; decimal... (5 Replies)
Discussion started by: Toorop
5 Replies

7. Shell Programming and Scripting

Help with number field manipulation

I have a comma separated file containing numbers, I would like to read the file and divide each number by 1024 and create an output file. Input file : 50312.00,3434.05, ,3433.34,124344.00,434343.00, , , Output file: 49.13,3.35,3.35,0,12.05,424.16,0,0 Please click this link: How to... (2 Replies)
Discussion started by: inditopgun
2 Replies

8. Shell Programming and Scripting

Use GREP to count number of records and place it in a variable

I am trying to count the number of records from different files using grep, and then place the result in a separate variable for each file, so at the end of my shell script, I can sum all the variables and check if the number of records are equal to what I was expecting. It is weird butwc -ldoes... (2 Replies)
Discussion started by: dhruuv369
2 Replies

9. Shell Programming and Scripting

sed flat file manipulation

Hello, I have a large flat file where i need to change data in columns 131-133 based on what is in columns 172-173. I am not sure if I need to read the file line by line and make the change or if I can do this in a single statement. thank you (3 Replies)
Discussion started by: gblmin
3 Replies

10. Shell Programming and Scripting

Zero padding a Number before and after a decimal place

Hi I was hoping someone could help me with a sed script I am trying to write? I am on a Mac running ElCapitan I have some text that I have converted from a pdf that I want to format into an xml file. In the file I have managed to delete all the text I do not need. The text I have left is... (8 Replies)
Discussion started by: Paul Walker
8 Replies
iswalnum(3)						     Library Functions Manual						       iswalnum(3)

NAME
iswalnum, iswalpha, iswcntrl, iswdigit, iswgraph, iswlower, iswprint, iswpunct, iswspace, iswupper, iswxdigit - Classify a wide character LIBRARY
Standard C Library (libc) SYNOPSIS
#include <wctype.h> int iswalnum( wint_t wc); int iswalpha( wint_t wc); int iswcntrl( wint_t wc); int iswdigit( wint_t wc); int iswgraph( wint_t wc); int iswlower( wint_t wc); int iswprint( wint_t wc); int iswpunct( wint_t wc); int iswspace( wint_t wc); int iswupper( wint_t wc); int iswxdigit( wint_t wc); STANDARDS
Interfaces documented on this reference page conform to industry standards as follows: iswalnum(), iswalpha(), iswcntrl(), iswdigit(), iswgraph(), iswlower(), iswprint(), iswpunct(), iswspace(), iswupper(), iswxdigit(): XSH5.0 Refer to the standards(5) reference page for more information about industry standards and associated tags. PARAMETERS
Specifies a wide character for testing. DESCRIPTION
These functions test a wide character wc for membership in a character class in the current locale. Each function tests to see if a wide character is part of a different character class. If the wide character is part of the character class, these functions return a nonzero value for true; otherwise, they return a value of 0 (zero) for false. Each function is named by adding the prefix isw to the name of the character class that the function tests. For example, the iswalpha() function tests whether the wide character specified by the wc parameter belongs to the alpha class. The following list identifies each function and describes the conditions under which it returns a true value: When wc is a character of class alpha or class digit in the program's current locale. When wc is a character of class alpha in the program's current locale. Charac- ters in classes lower and upper automatically belong to class alpha. When wc is a character of class cntrl in the program's current locale. When wc is a character of class digit in the program's current locale. The following characters are included in this class: 0 1 2 3 4 5 6 7 8 9 When wc is a character of class graph in the program's current locale. Characters in classes alpha, digit, and punct are automatically in class graph. Unlike iswprint(), iswgraph() returns FALSE for the space character. When wc is a charac- ter of class lower in the program's current locale. At a minimum, the 26 lowercase US-ASCII characters are included in this class. These are: a b c d e f g h i j k l m n o p q r s t u v w x y z When wc is a character of class print in the program's current locale. All char- acters in the class graph and the space character are automatically included in class print. When wc is a character of class punct in the program's current locale. When wc is a character of class space in the program's current locale. At a minimum, the space, form-feed, newline, carriage-return, tab, and vertical-tab characters are included in this class. When wc is a character of class upper in the program's current locale. At a minimum, the 26 uppercase US-ASCII characters are included in this class. These are: A B C D E F G H I J K L M N O P Q R S T U V W X Y Z When wc is a character of class xdigit in the program's current locale. The fol- lowing characters are included in this class: 0 1 2 3 4 5 6 7 8 9 A B C D E F a b c d e f These functions determine the class of a wide character based on the LC_CTYPE locale category. NOTES
[Tru64 UNIX] The iswdigit(), iswxdigit(), and iswalnum() functions do not recognize Thai digits. Many applications make assumptions about how a digit character can be converted to its numeric equivalent. Changing the functions to recognize Thai digits would break these appli- cations. Refer to TACTIS(5) for more information about Thai digits. RETURN VALUES
If the wide character tested is part of the particular character class, these functions return a nonzero value; otherwise, they return a value of 0 (zero). RELATED INFORMATION
Files: locale(4) Functions: ctype(3), iswctype(3), setlocale(3), tolower(3), towctrans(3), towlower(3), wctrans(3), wctype(3) Others: i18n_intro(5), l10n_intro(5), standards(5) delim off iswalnum(3)
All times are GMT -4. The time now is 07:58 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy