Sponsored Content
Top Forums Shell Programming and Scripting reformating non-uniform strings Post 302439005 by joeyg on Wednesday 21st of July 2010 10:58:47 AM
Old 07-21-2010
Tools To do that with extensions...

I am thinking about
sprintf = formatted printing
gsub = global substitution
as useful functions within awk to help you.

(Sorry, kinda busy right now to think thru, but wanted to provide some thoughts)
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help on awk.. reformating a file

Hello, I am having a trouble with awk attempting to reformat a two columns file , such as below: 201 84 201 370 201 544 201 600 213 99 213 250 213 431 220 65 220 129 220 338 220 408 220 501 220 550 231 101 231 350 What I need to do is is to add a third column containing a... (4 Replies)
Discussion started by: Martian
4 Replies

2. Shell Programming and Scripting

awk - reformating rows into columns

looking to do the following... What the data looks like server1 02/01/2008 groups 10 server1 03/01/2008 groups 15 server1 04/01/2008 groups 20 server2 02/01/2008 users 50 server2 03/01/2008 users 75 server2 04/01/2008 users 100 server2 04/01/2008 users 125 What I would like the... (1 Reply)
Discussion started by: jmd2004
1 Replies

3. UNIX for Advanced & Expert Users

Selectively Reformating a file using AWK

Dear users, I am new to AWK and have been battling with this one for close to a week now. Some of you did offer some help last week but I think I may not have explained myself very well. So I am trying again. I have a dataset that has the following format where the datasets repeat every... (5 Replies)
Discussion started by: sda_rr
5 Replies

4. Shell Programming and Scripting

Reformating ascii file with awk

Hello, I've a lot of ascii files that I would like to reformat : One of files's column (for exemple $5) contains increasing numbers (see exemple) : $5= 1 1 1 1 1 2 2 2 2 3 3 (2 Replies)
Discussion started by: Caribou
2 Replies

5. Shell Programming and Scripting

Rows to columns transposing and reformating.

----File attached. Input file =========== COL_1 <IP Add 1> COL_2 <Service1> COL_3 <ABCDEFG> COL_4 <IP ADD:PORT> COL_4 <IP ADD:PORT> COL_1 <IP Add 2> COL_2 <Service2> COL_2 <Service3> COL_2 <Service4> COL_3 <AAAABBB> COL_4 <IP ADD:PORT> COL_4 <IP ADD:PORT> COL_4 <IP... (27 Replies)
Discussion started by: bluethunder
27 Replies

6. Shell Programming and Scripting

Splitting & reformating a single file

I have a bif text file with the following format: d1_03 fr:23 d1_03 fr:56 d1_03 fr:67 d1_03 fr:78 d1_01 fr:35 d1_01 fr:29 d1_01 fr:45 d2_09 fr:34 d2_09 fr:78 d3_98 fr:90 d3_98 fr:104 d3_98 fr:360 I have like thousands of such lines I want to reformat this file based on column 1... (3 Replies)
Discussion started by: Lucky Ali
3 Replies

7. UNIX for Dummies Questions & Answers

Reformating unix data

Hi i have a unix date in file a file like this '1313675999' in oracle i would do it like this select TO_CHAR ( TO_DATE ('01011970', 'DDMMYYYY')+ 1 / 24 / 60 / 60 * 1313675999,'YYYYMMDD') from dual how to achive the same in unix ? (8 Replies)
Discussion started by: phpsnook
8 Replies

8. Shell Programming and Scripting

Searching for strings amongst non-uniform data

Hi Guys, I have a source file which contains significant strings amongst a lot of dross in non-uniform format, I'd like to search the input file for any examples of data from my reference file, and then output any matches to a list (text file). I've made something that achieves this, it's... (4 Replies)
Discussion started by: gazza86
4 Replies

9. AIX

Uniform LUN size

Hi, Is there any advantage is making all my storage LUNS ( hdisk ) of uniform size. Currently the LUN's are having different size () eg: 50G / 60G / 75G etc ). I am planning for a storage migration....so should i go for uniform lun size or with current LUN size pattern ? Regards, jibu (3 Replies)
Discussion started by: jibujacob
3 Replies

10. Shell Programming and Scripting

Uniform Spacing in the message

Hello, I am running a script which sends an output as an email; I am having issues with the spacing being not uniform in the message. Snippet of the code and email message below: if ] then echo "$Hostname\tMISSING\tHMCBackup" >> $BackupMsg else if ] then echo... (12 Replies)
Discussion started by: hasn318
12 Replies
explain_sprintf(3)					     Library Functions Manual						explain_sprintf(3)

NAME
explain_sprintf - explain sprintf(3) errors SYNOPSIS
#include <libexplain/sprintf.h> const char *explain_sprintf(char *data, const char *format, ...); const char *explain_errno_sprintf(int errnum, char *data, const char *format, ...); void explain_message_sprintf(char *message, int message_size, char *data, const char *format, ...); void explain_message_errno_sprintf(char *message, int message_size, int errnum, char *data, const char *format, ...); DESCRIPTION
These functions may be used to obtain explanations for errors returned by the sprintf(3) system call. explain_sprintf const char *explain_sprintf(char *data, const char *format, ...); The explain_sprintf function is used to obtain an explanation of an error returned by the sprintf(3) system call. The least the message will contain is the value of strerror(errno), but usually it will do much better, and indicate the underlying cause in more detail. The errno global variable will be used to obtain the error value to be decoded. data The original data, exactly as passed to the sprintf(3) system call. format The original format, exactly as passed to the sprintf(3) system call. Returns: The message explaining the error. This message buffer is shared by all libexplain functions which do not supply a buffer in their argument list. This will be overwritten by the next call to any libexplain function which shares this buffer, including other threads. Note: This function is not thread safe, because it shares a return buffer across all threads, and many other functions in this library. Example: This function is intended to be used in a fashion similar to the following example: errno = EINVAL; int result = sprintf(data, format, ...); if (result < 0) { fprintf(stderr, "%s ", explain_sprintf(data, format, ...)); exit(EXIT_FAILURE); } The above code example is available pre-packaged as the explain_sprintf_or_die(3) function. explain_errno_sprintf const char *explain_errno_sprintf(int errnum, char *data, const char *format, ...); The explain_errno_sprintf function is used to obtain an explanation of an error returned by the sprintf(3) system call. The least the mes- sage will contain is the value of strerror(errno), but usually it will do much better, and indicate the underlying cause in more detail. errnum The error value to be decoded, usually obtained from the errno global variable just before this function is called. This is neces- sary if you need to call any code between the system call to be explained and this function, because many libc functions will alter the value of errno. data The original data, exactly as passed to the sprintf(3) system call. format The original format, exactly as passed to the sprintf(3) system call. Returns: The message explaining the error. This message buffer is shared by all libexplain functions which do not supply a buffer in their argument list. This will be overwritten by the next call to any libexplain function which shares this buffer, including other threads. Note: This function is not thread safe, because it shares a return buffer across all threads, and many other functions in this library. Example: This function is intended to be used in a fashion similar to the following example: errno = EINVAL; int result = sprintf(data, format, ...); if (result < 0) { int err = errno; fprintf(stderr, "%s ", explain_errno_sprintf(err, data, format, ...)); exit(EXIT_FAILURE); } The above code example is available pre-packaged as the explain_sprintf_or_die(3) function. explain_message_sprintf void explain_message_sprintf(char *message, int message_size, char *data, const char *format, ...); The explain_message_sprintf function is used to obtain an explanation of an error returned by the sprintf(3) system call. The least the message will contain is the value of strerror(errno), but usually it will do much better, and indicate the underlying cause in more detail. The errno global variable will be used to obtain the error value to be decoded. message The location in which to store the returned message. If a suitable message return buffer is supplied, this function is thread safe. message_size The size in bytes of the location in which to store the returned message. data The original data, exactly as passed to the sprintf(3) system call. format The original format, exactly as passed to the sprintf(3) system call. Example: This function is intended to be used in a fashion similar to the following example: errno = EINVAL; int result = sprintf(data, format, ...); if (result < 0) { char message[3000]; explain_message_sprintf(message, sizeof(message), data, format, ...); fprintf(stderr, "%s ", message); exit(EXIT_FAILURE); } The above code example is available pre-packaged as the explain_sprintf_or_die(3) function. explain_message_errno_sprintf void explain_message_errno_sprintf(char *message, int message_size, int errnum, char *data, const char *format, ...); The explain_message_errno_sprintf function is used to obtain an explanation of an error returned by the sprintf(3) system call. The least the message will contain is the value of strerror(errno), but usually it will do much better, and indicate the underlying cause in more detail. message The location in which to store the returned message. If a suitable message return buffer is supplied, this function is thread safe. message_size The size in bytes of the location in which to store the returned message. errnum The error value to be decoded, usually obtained from the errno global variable just before this function is called. This is neces- sary if you need to call any code between the system call to be explained and this function, because many libc functions will alter the value of errno. data The original data, exactly as passed to the sprintf(3) system call. format The original format, exactly as passed to the sprintf(3) system call. Example: This function is intended to be used in a fashion similar to the following example: errno = EINVAL; int result = sprintf(data, format, ...); if (result < 0) { int err = errno; char message[3000]; explain_message_errno_sprintf(message, sizeof(message), err, data, format, ...); fprintf(stderr, "%s ", message); exit(EXIT_FAILURE); } The above code example is available pre-packaged as the explain_sprintf_or_die(3) function. SEE ALSO
sprintf(3) formatted output conversion explain_sprintf_or_die(3) formatted output conversion and report errors COPYRIGHT
libexplain version 0.52 Copyright (C) 2010 Peter Miller explain_sprintf(3)
All times are GMT -4. The time now is 05:52 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy