Sponsored Content
Top Forums Shell Programming and Scripting Help awk/sed: putting a space after numbers:to separate number and characters. Post 302775811 by Scrutinizer on Tuesday 5th of March 2013 12:32:00 PM
Old 03-05-2013
@mirni. That would work in this case, but if if there is also text that begins with a non-digit then as space would be inserted at the start of the line.. To avoid that one could use:
Code:
sed 's/^[0-9][0-9]*/& /' file

@bipinajiith, the same applies to your awk approach..
These 3 Users Gave Thanks to Scrutinizer For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

how to separate every 10 characters then space then another 10 charactes

suppose u have a file P2122 AAJJSKKSKSLSKSKMSKMS P2123 AASSJMWJNSJNWHNSKSJ P2126 AHJMKNSAJNSKAKMOKALM P3533 KKKSJMAKKLLMLMSLMSPM P2122 JKKSKKMKKSKKKS--------------NSNJ P2123 NSJN---------MSKMKMKKSLLNSLL P2126 JNJSJNWKMSK-------------SKKSMK P3533 JSNSNPWLLL-SKK----SKKKSKKS so the... (2 Replies)
Discussion started by: cdfd123
2 Replies

2. Shell Programming and Scripting

Putting a character between two other characters?

I need to separate Pascal style identifiers (TheyLookLikeThis) into words separated by an underscore (_). I've tried sed 's//&_&/' but this won't work (obviously). I'd love some help. (4 Replies)
Discussion started by: Ilja
4 Replies

3. Shell Programming and Scripting

Separate date timestamp use awk or sed command ?

Hi, I have logfile like this : Actually the format is date format : yyyymmddHHMMSS and i want the log become this format yyyy-mm-dd HH:MM:SS for example 2009-07-19 11:46:52 Can somebody help me ? Thanks in advance (3 Replies)
Discussion started by: justbow
3 Replies

4. Shell Programming and Scripting

AWK to separate numbers from logs

Hello friends, Im trying to separate a number from a log, but it seems i need help here awk '/stimated/ {print $5}' mylog.txt gives (1515.45MB). i need pure number part to use in a comparision loop so i want to separate the number part (but only 1515 not 1515.45 ) awk '/stimated/... (6 Replies)
Discussion started by: EAGL€
6 Replies

5. Shell Programming and Scripting

Concatenating lines of separate files using awk or sed

For example: File 1: abc def ghi jkl mno pqr File 2: stu vwx yza bcd efg hij klm nop qrs I want the reult to be: abc def ghistu vwx yza jkl mno pqrbcd efg hij klm nop qrs (4 Replies)
Discussion started by: tamahomekarasu
4 Replies

6. Shell Programming and Scripting

Insert space between characters using sed

Input: Youcaneasilydothisbyhighlightingyourcode. Putting space after three characters. You can eas ily dot his byh igh lig hti ngy our cod e. How can i do this using sed? (10 Replies)
Discussion started by: cola
10 Replies

7. Shell Programming and Scripting

awk/sed script to print each line to a separate named file

I have a large 3479 line .csv file, the content of which looks likes this: 1;0;177;170;Guadeloupe;x 2;127;171;179;Antigua and Barbuda;x 3;170;144;2;Umpqua;x 4;170;126;162;Coos Bay;x ... 1205;46;2;244;Unmak Island;x 1206;47;2;248;Yunaska Island;x 1207;0;2;240;north sea;x... (5 Replies)
Discussion started by: kalelovil
5 Replies

8. Programming

putting numbers behind eachother

I want to make a program where you have to insert binary numbers like this: do { iBinary = getche(); }while(iBinary == 1 || iBinary == 0); after you get the numbers I want them to be placed behind eachother so you will get: input: 1 1 0 1 output: 1101 (7 Replies)
Discussion started by: metal005
7 Replies

9. Shell Programming and Scripting

How to ignore characters and print only numbers using awk?

Input: ak=70&cat15481=lot=6991901">Kaschau (1820-1840) ak=7078&cat15482=lot=70121">Principauté (1940-1993) ak=709&cat=lot15484=70183944">Arubas (4543-5043)Output: 70 15481 6991901 7078 15482 70121 709 15484 70183944 (11 Replies)
Discussion started by: sdf
11 Replies

10. Shell Programming and Scripting

[Solved] How to separate one line to mutiple line based on certain number of characters?

hi Gurus, I need separate a file which is one huge line to multiple lines based on certain number of charactors. for example: abcdefghi high abaddffdd I want to separate the line to multiple lines for every 4 charactors. the result should be abcd efgh i hi gh a badd ffdd Thanks in... (5 Replies)
Discussion started by: ken6503
5 Replies
strtoul(3C)						   Standard C Library Functions 					       strtoul(3C)

NAME
strtoul, strtoull - convert string to unsigned long SYNOPSIS
#include <stdlib.h> unsigned long strtoul(const char *restrict str, char **restrict endptr, int base); unsigned long long strtoull(const char *restrict str, char **restrict endptr, int base); DESCRIPTION
The strtoul() function converts the initial portion of the string pointed to by str to a type unsigned long int representation. First it decomposes the input string into three parts: an initial, possibly empty, sequence of white-space characters (as specified by isspace(3C)); a subject sequence interpreted as an integer represented in some radix determined by the value of base; and a final string of one or more unrecognised characters, including the terminating null byte of the input string. Then it attempts to convert the subject sequence to an unsigned integer, and returns the result. If the value of base is 0, the expected form of the subject sequence is that of a decimal constant, octal constant or hexadecimal constant, any of which may be preceded by a + or - sign. A decimal constant begins with a non-zero digit, and consists of a sequence of decimal dig- its. An octal constant consists of the prefix 0 optionally followed by a sequence of the digits 0 to 7 only. A hexadecimal constant con- sists of the prefix 0x or 0X followed by a sequence of the decimal digits and letters a (or A) to f (or F) with values 10 to 15 respec- tively. If the value of base is between 2 and 36, the expected form of the subject sequence is a sequence of letters and digits representing an integer with the radix specified by base, optionally preceded by a + or - sign. The letters from a (or A) to z (or Z) inclusive are ascribed the values 10 to 35; only letters whose ascribed values are less than that of base are permitted. If the value of base is 16, the characters 0x or 0X may optionally precede the sequence of letters and digits, following the sign if present. The subject sequence is defined as the longest initial subsequence of the input string, starting with the first non-white-space character, that is of the expected form. The subject sequence contains no characters if the input string is empty or consists entirely of white-space characters, or if the first non-white-space character is other than a sign or a permissible letter or digit. If the subject sequence has the expected form and the value of base is 0, the sequence of characters starting with the first digit is interpreted as an integer constant. If the subject sequence has the expected form and the value of base is between 2 and 36, it is used as the base for conversion, ascribing to each letter its value as given above. If the subject sequence begins with a minus sign, the value resulting from the conversion is negated. A pointer to the final string is stored in the object pointed to by endptr, provided that endptr is not a null pointer. In other than the POSIX locale, additional implementation-dependent subject sequence forms may be accepted. If the subject sequence is empty or does not have the expected form, no conversion is performed; the value of str is stored in the object pointed to by endptr, provided that endptr is not a null pointer. The strtoull() function is identical to strtoul() except that it returns the value represented by str as an unsigned long long. RETURN VALUES
Upon successful completion strtoul() returns the converted value, if any. If no conversion could be performed, 0 is returned and errno may be set to EINVAL. If the correct value is outside the range of representable values, ULONG_MAX is returned and errno is set to ERANGE. ERRORS
The strtoul() function will fail if: EINVAL The value of base is not supported. ERANGE The value to be returned is not representable. The strtoul() function may fail if: EINVAL No conversion could be performed. USAGE
Because 0 and ULONG_MAX are returned on error and are also valid returns on success, an application wishing to check for error situations should set errno to 0, then call strtoul(), then check errno and if it is non-zero, assume an error has occurred. Unlike strtod(3C) and strtol(3C), strtoul() must always return a non-negative number; so, using the return value of strtoul() for out-of- range numbers with strtoul() could cause more severe problems than just loss of precision if those numbers can ever be negative. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Interface Stability |Standard | +-----------------------------+-----------------------------+ |MT-Level |MT-Safe | +-----------------------------+-----------------------------+ SEE ALSO
isalpha(3C), isspace(3C), scanf(3C), strtod(3C), strtol(3C), attributes(5), standards(5) SunOS 5.10 1 Nov 2003 strtoul(3C)
All times are GMT -4. The time now is 04:31 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy