Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Parsing alphanumeric variables Post 302564938 by alpesh on Saturday 15th of October 2011 02:35:17 PM
Old 10-15-2011
Parsing alphanumeric variables

Hi All,

I have files with a column which has values and ranges, for example

colA colB
ERD1 3456
ERD2 [526887..526890]
ERD3 4456

I want to have the following output
colA colB colC
ERD1 3456 3456
ERD2 526887 526890
ERD3 4456 4456

Being a newbie to shell scripting ,I`m struggling to find the right commands.

Question 2.

I have an array of alphanumeric variables like 24S45M67N45M, 367M, 23M3D34M etc. There will be at least 1 M and at most 2 Ms in the strings
while the other alphabets may or may not be present.
I want to extract the number associated with the Ms. So the output will look like
24S45M67N45M 45 45
367M 367 0
23M3D34M 23 34

Please help !

Thanks,
Alpesh

So the ou at least 1
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Parsing and getting values of variables

suppose i have a file value where it returns 3 values a=1 b=2 c=4 when i run it. i am using this file in my shell script. how do i parse and get the value of a b and c? (3 Replies)
Discussion started by: Rekha
3 Replies

2. Shell Programming and Scripting

alphanumeric comparision

I have a requirement where I need to check if where r1v07l09ab is a software release. I should always check for this to be true to continue the release deployment because an older release should not be deployed by mistake. I mean only the release greater than the current release should be... (3 Replies)
Discussion started by: rakeshou
3 Replies

3. Shell Programming and Scripting

Perl: parsing variables

I have the following script: #!/usr/bin/perl -w @files = <*.csv>; foreach $file (@files) { open(FH, $file); my @dt = split(/_|.csv/, $file); while (<FH>) { chomp; print $dt . $dt . ",$_\n"; } close(FH); } This script reads in all csv files in the current directory... (2 Replies)
Discussion started by: figaro
2 Replies

4. Shell Programming and Scripting

Parsing Directory Names for Use as Bash Variables

Hi all: I have a directory where all of the subdirectories are named by the convention "images_#1:#2_Date." My goal is to get an array for each subdirectory that has the structure (#1,#2, int). I am able to use awk to print each subdirectory's values, but cannot figure out how to get them into an... (6 Replies)
Discussion started by: aefskysa
6 Replies

5. UNIX for Advanced & Expert Users

alphanumeric Sorting

Hi , I have a requirement where one column have to be sorted (delimiter is pipe) for eg: My input filed is as below 1|FIAT|0010103|23011|01/01/2000|31/12/9999|1.15 2|232|613|1 2|234|743|1 2|234|793|1 2|234|893|1 1|FIAT|0010103|23012|01/01/2000|31/12/9999|1.15 2|230|006|0 2|230|106|0... (9 Replies)
Discussion started by: laxmi131
9 Replies

6. Shell Programming and Scripting

Help parsing logs maybe with menu and variables?

I would like to parse through some logs looking for things like exception or failed (grep -i failed). Ideal would be if it were in a menu format so someone without unix ability could just choose option 1 2 or 3 etc. If I could pass the hostname to a variable also that would be awesome, so someone... (5 Replies)
Discussion started by: taekwondo
5 Replies

7. UNIX for Dummies Questions & Answers

Issue with parsing config variables

I am using MKS tool kit on windows server. One config variable is defined in windows environment and I am trying to use that variable. # Below RootDir is defined in windows RootDir="\\f01\var" # in unix script details="$RootDir/src|$RootDir/tgt" src=`echo $details|awk -F '|' '{print... (1 Reply)
Discussion started by: madhukalyan
1 Replies

8. Shell Programming and Scripting

Comparing Alphanumeric Variables in Shell Script

Can someone please help me out here? I have strings similar to aafafaff45,29.34.942.45,edfdfafa that i want to compare to another similar string to check if they are the same. my script isn't working. ONE="aafafaff45,29.34.942.45,edfdfafa" TWO="ddfafagfa,87.57.942.45,afafafff" if ONE is... (5 Replies)
Discussion started by: SkySmart
5 Replies

9. Shell Programming and Scripting

Parsing fields into variables

A record contains 50 fields separated by "~". I need to assign each of these fields to different variables. Following is the shell script approach I tried. RECORD="FIELD1~FIELD2~FIELD3~FIELD4~FIELD5~...........~FIELD50" VAR1=$(echo ${RECORD} | cut -d"~" -f 1) VAR2=$(echo ${RECORD} | cut... (5 Replies)
Discussion started by: krishmaths
5 Replies

10. Shell Programming and Scripting

Parsing a file and setting to variables.

greetings all, I have a task right now that is somewhat stumping me, and I am not sure what the best approach is to take it. I have a text file that will contain something similar to the following: first1, other1 first2, other2 first3, other3 first4, other4 I have to generate an... (14 Replies)
Discussion started by: jeffs42885
14 Replies
STRFROMD(3)						     Linux Programmer's Manual						       STRFROMD(3)

NAME
strfromd, strfromf, strfroml - convert a floating-point value into a string SYNOPSIS
#include <stdlib.h> int strfromd(char *restrict str, size_t n, const char *restrict format, double fp); int strfromf(char *restrict str, size_t n, const char *restrict format, float fp); int strfroml(char *restrict str, size_t n, const char *restrict format, long double fp); Feature Test Macro Requirements for glibc (see feature_test_macros(7)): strfromd(), strfromf(), strfroml(): __STDC_WANT_IEC_60559_BFP_EXT__ DESCRIPTION
These functions convert a floating-point value, fp, into a string of characters, str, with a configurable format string. At most n charac- ters are stored into str. The terminating null character ('') is written if and only if n is sufficiently large, otherwise the written string is truncated at n characters. The strfromd(), strfromf(), and strfroml() functions are equivalent to snprintf(str, n, format, fp); except for the format string. Format of the format string The format string must start with the character '%'. This is followed by an optional precision which starts with the period character (.), followed by an optional decimal integer. If no integer is specified after the period character, a precision of zero is used. Finally, the format string should have one of the conversion specifiers a, A, e, E, f, F, g, or G. The conversion specifier is applied based on the floating-point type indicated by the function suffix. Therefore, unlike snprintf(), the format string does not have a length modifier character. See snprintf(3) for a detailed description of these conversion specifiers. The implementation conforms to the C99 standard on conversion of NaN and infinity values: If fp is a NaN, +NaN, or -NaN, and f (or a, e, g) is the conversion specifier, the conversion is to "nan", "nan", or "-nan", respec- tively. If F (or A, E, G) is the conversion specifier, the conversion is to "NAN" or "-NAN". Likewise if fp is infinity, it is converted to [-]inf or [-]INF. A malformed format string results in undefined behavior. RETURN VALUE
The strfromd(), strfromf(), and strfroml() functions return the number of characters that would have been written in str if n had enough space, not counting the terminating null character. Thus, a return value of n or greater means that the output was truncated. VERSIONS
The strfromd(), strfromf(), and strfroml() functions are available in glibc since version 2.25. ATTRIBUTES
For an explanation of the terms used in this section, see attributes(7) and the POSIX Safety Concepts section in GNU C Library manual. +------------+----------------------------------+----------------+ |Interface | Attribute | Value | +------------+----------------------------------+----------------+ | | Thread safety | MT-Safe locale | |strfromd(), +----------------------------------+----------------+ |strfromf(), | Asynchronous signal safety | AS-Unsafe heap | |strfroml() +----------------------------------+----------------+ | | Asynchronous cancellation safety | AC-Unsafe mem | +------------+----------------------------------+----------------+ Note: these attributes are preliminary. CONFORMING TO
C99, ISO/IEC TS 18661-1. NOTES
The strfromd(), strfromf(), and strfroml() functions take account of the LC_NUMERIC category of the current locale. EXAMPLES
To convert the value 12.1 as a float type to a string using decimal notation, resulting in "12.100000": #define __STDC_WANT_IEC_60559_BFP_EXT__ #include <stdlib.h> int ssize = 10; char s[ssize]; strfromf(s, ssize, "%f", 12.1); To convert the value 12.3456 as a float type to a string using decimal notation with two digits of precision, resulting in "12.35": #define __STDC_WANT_IEC_60559_BFP_EXT__ #include <stdlib.h> int ssize = 10; char s[ssize]; strfromf(s, ssize, "%.2f", 12.3456); To convert the value 12.345e19 as a double type to a string using scientific notation with zero digits of precision, resulting in "1E+20": #define __STDC_WANT_IEC_60559_BFP_EXT__ #include <stdlib.h> int ssize = 10; char s[ssize]; strfromd(s, ssize, "%.E", 12.345e19); SEE ALSO
atof(3), snprintf(3), strtod(3) COLOPHON
This page is part of release 4.15 of the Linux man-pages project. A description of the project, information about reporting bugs, and the latest version of this page, can be found at https://www.kernel.org/doc/man-pages/. GNU
2017-09-15 STRFROMD(3)
All times are GMT -4. The time now is 05:34 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy