Sponsored Content
Top Forums Shell Programming and Scripting Help awk/sed: putting a space after numbers:to separate number and characters. Post 302775805 by Yoda on Tuesday 5th of March 2013 12:24:58 PM
Old 03-05-2013
Another approach:
Code:
awk '{ match($0,/^[0-9]*/); print substr($0, RSTART, RLENGTH) " " substr($0, RSTART+RLENGTH) } ' file

This User Gave Thanks to Yoda 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
ddi_strtol(9F)						   Kernel Functions for Drivers 					    ddi_strtol(9F)

NAME
ddi_strtol - String conversion routines SYNOPSIS
#include <sys/ddi.h> #include <sys/sunddi.h> int ddi_strtol(const char *str, char **endptr, int base, long *result); INTERFACE LEVEL
Solaris DDI specific (Solaris DDI) PARAMETERS
str Pointer to a character string to be converted. endptr Post-conversion final string of unrecognized characters. base Radix used for conversion. result Pointer to variable which contains the converted value. DESCRIPTION
The ddi_strtol() function converts the initial portion of the string pointed to by str to a type long int representation and stores the converted value in result. The function first decomposes the input string into three parts: 1. An initial (possibly empty) sequence of white-space characters (' ', ' ', ' ', ' ', 'f') 2. A subject sequence interpreted as an integer represented in some radix determined by the value of base 3. A final string of one or more unrecognized characters, including the terminating null byte of the input string. The ddi_strtol() function then attempts to convert the subject sequence to an integer and returns the result. If the value of base is 0, the expected form of the subject sequence is a decimal constant, octal constant or hexadecimal constant, any of which may be preceded by a plus ("+") or minus ("-") sign. A decimal constant begins with a non-zero digit, and consists of a sequence of decimal digits. An octal constant consists of the prefix 0 optionally followed by a sequence of the digits 0 to 7 only. A hexadecimal constant consists 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 respectively. 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 plus or minus sign. The letters from a (or A) to z (or Z) inclusive are ascribed the values 10 to 35 and 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. If the subject sequence is empty or does not have the expected form, no conversion is performed and the value of str is stored in the object pointed to by endptr, provided that endptr is not a null pointer. RETURN VALUES
Upon successful completion, ddi_strtol() returns 0 and stores the converted value in result. If no conversion is performed due to invalid base, ddi_strtol() returns EINVAL and the variable pointed by result is not changed. If the correct value is outside the range of representable values, ddi_strtol() returns ERANGE and the value pointed to by result is not changed. CONTEXT
The ddi_strtol() function may be called from user, kernel or interrupt context. SEE ALSO
Writing Device Drivers SunOS 5.10 13 May 2004 ddi_strtol(9F)
All times are GMT -4. The time now is 01:35 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy