Sponsored Content
Top Forums Shell Programming and Scripting NAWK: changing string-format with split Post 302559763 by regisl67 on Wednesday 28th of September 2011 05:13:05 AM
Old 09-28-2011
Uh?! It was so simple ... and works perfect. Thank you very much for your help! Régis
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Nawk Split

Hello. I have a input file in this format: line1data :: line1data :: line1data line2data :: line2data :: line2data I would like to split each lines data element into an array: array1=line1data array1=line1data array1=line1data array2=line2data array2=line2data array2=line2data I... (3 Replies)
Discussion started by: steveramsey
3 Replies

2. UNIX for Dummies Questions & Answers

Split BIG report using nawk

I have the following nawk script: nawk -F: '{ if($0 ~ "^Report No") {fl=1; i=0;} if(fl==1){data=$0; i++} if($0 ~ "^BE NO:") { fname = "reprot_"$2".lis"; gsub(" ","",fname); for(j=0;j<i;j++) print data > fname; fl=0; } else if(fl==0) print $0 > fname; }' filename When I try to apply... (1 Reply)
Discussion started by: raychu65
1 Replies

3. Shell Programming and Scripting

changing month in Mmm format to mm FORMAT

i have an variable mydate=2008Nov07 i want o/p as in variable mymonth=11 (i.e nov comes on 11 number month) i want some command to do this for any month without using any loop. plz help me (1 Reply)
Discussion started by: RahulJoshi
1 Replies

4. Shell Programming and Scripting

awk/nawk question to format a file

Hi, I am new to awk/nawk, needs help. I want to merge the rows having emplid attribute same into a single row in the following file. In actual this kind of file will have around 50k rows. Here is my input file id|emplid|firstname|dep|lastname 1|001234|test|1001|1 2|002345|test|1032|2... (7 Replies)
Discussion started by: kumar04
7 Replies

5. Shell Programming and Scripting

Format - Inventory Row data into Column - Awk - Nawk

Hi All, I have the following file that has computer data for various pcs in my network... Snap of the file is as follows ******************************************************************************* Serial 123456 Computer IP Address lo0:... (1 Reply)
Discussion started by: aavam
1 Replies

6. UNIX for Dummies Questions & Answers

Changing from Excel date format to MySQL date format

I have a list of dates in the following format: mm/dd/yyyy and want to change these to the MySQL standard format: yyyy-mm-dd. The dates in the original file may or may not be zero padded, so April is sometimes "04" and other times simply "4". This is what I use to change the format: sed -i '' -e... (2 Replies)
Discussion started by: figaro
2 Replies

7. Shell Programming and Scripting

how to parse the file in xml format using awk/nawk

Hi All, I have an xml file with the below format. <a>111</a><b>222</b><c>333<c><d><e>123</e><f>234</f><d><e>456</e><f>789</f> output needed is 111,222,333,123,234 111,222,333,456,789 nawk 'BEGIN{FS="<|>"} {print a,b,c,e,f a="" ... (7 Replies)
Discussion started by: natalie23
7 Replies

8. Shell Programming and Scripting

Nawk Format

Hi! I have a file which I want to search daily for any line that contains the work 'Reason' and I want to take that line and put the data in a certain format using awk or nawk....I do not have gawk on my machine so it would have to be awk or nawk, or sed would work as well. Here are some examples... (9 Replies)
Discussion started by: ther2000
9 Replies

9. Shell Programming and Scripting

Using awk or nawk to convert epoch time to date format

Looking for some help and usually when I do a search this site comes up. Hopefully someone can give me a little direction as to how to use one of these two commands to achieve what I'm trying to do. What am I trying to do? I need to take the time value in epoch format returned from the... (5 Replies)
Discussion started by: minigts
5 Replies

10. UNIX for Beginners Questions & Answers

Date format conversion how to change this from using nawk to awk

Hi, I have a file where I need to change the date format on the nth field from DD-MM-YYYY to YYYY-MM-DD so I can accurately sort the record by dates From regex - Use sed or awk to fix date format - Stack Overflow, I found an example using nawk. Test run as below: $: cat xyz.txt A ... (2 Replies)
Discussion started by: newbie_01
2 Replies
KDB 
:: High Level methods(3) Library Functions Manual KDB :: High Level methods(3) NAME
KDB :: High Level methods - High level methods to access the Key database. Functions int kdbGetKey (KDB *handle, Key *dest) int kdbSetKey (KDB *handle, const Key *key) int kdbGetString (KDB *handle, const char *keyname, char *returned, size_t maxSize) int kdbSetString (KDB *handle, const char *keyname, const char *value) int kdbRemove (KDB *handle, const char *keyname) ssize_t kdbGetByName (KDB *handle, KeySet *returned, const char *name, option_t options) Detailed Description High level methods to access the Key database. To use them: #include <kdb.h> These methods are higher level. They use kdbOpen(), kdbClose(), kdbGet() and kdbSet() methods to do their job, and don't have to be reimplemented for a different backend. These functions avoid limitations through not implemented capabilities. This will of course cost some effort, so read through the description carefully and decide if it is appropriate for your problem. Binding writers don't have to implement these functions, use features of the binding language instead. But you can use these functions as ideas what high level methods may be useful. Don't use writing single keys in a loop, prefer always writing out a keyset! Function Documentation ssize_t kdbGetByName (KDB *handle, KeySet *returned, const char *name, option_toptions) This method is similar kdbGet() but the path is given by a string. When it is not possible to make a key out of that string -1 is returned . When parentName starts with / cascading will be used and both keys from user and system will be fetched. A typically app with about 3000 keys may have this line: KDB *handle = kdbOpen(); KeySet *myConfig = (4096, KS_END); ssize_t ret = kdbGetByName (handle, myConfig, '/sw/app/current', 0); // check ret and work with keyset myConfig ksDel (myConfig); kdbClose (handle); * myConfig will be loaded with keys from system/sw/app/current but also user/sw/app/current. When one of these kdbGet() fails -1 will be returned, but the other kdbGet() will be tried too. Parameters: handle contains internal information of opened key database name the name where to get the keys below returned the (pre-initialized) KeySet returned with all keys found options ORed options to control approaches Unlike to kdbGet() is KDB_O_POP set per default. Returns: number of keys contained by returned -1 on failure -1 when name is no valid key -1 on NULL pointer See also: kdbGet() int kdbGetKey (KDB *handle, Key *dest) Fully retrieves the passed key from the backend storage. The backend will try to get the key, identified through its name. It uses kdbGet() for retrieving the key and copies the found data to dest. While kdbGetKey() is perfect for a simple get of a specific key, kdbGet() and kdbGetByName() gives you more control over the keyset. Parameters: handle contains internal information of opened key database dest a pointer to a Key that has a name set Returns: 0 on success -1 on failure -1 on NULL pointer See also: kdbSetKey() to set a single Key :: Basic Methods commandGet() code in KDB :: Low Level Methods command for usage example kdbGet() and kdbGetByName() to have more control over KeySet :: Class Methods and options int kdbGetString (KDB *handle, const char *keyname, char *returned, size_tmaxSize) A high-level method to get a key value, by key name. This method gets a backend from any backend with kdbGetKey() and extracts the string and store it into returned. It only works with string keys. This method gives you the direct relation between a keyname and the value, without any kdb specific structures. Use it when you just want some values out of the kdb namespace. You need to know the maximum string length of the object. That could be the case when you e.g. save a path which is limited with MAX_PATH. KDB *handle = kdbOpen(); char buffer [MAX_PATH]; if (kdbGetString(handle, 'user/key/to/get/pathname', buffer, sizeof(buffer)) == -1) { // handle error cases } else { printf ('The keys value is %s0, buffer); } kdbClose(handle); Parameters: handle contains internal information of opened key database keyname the name of the key to receive the value returned a buffer to put the key value maxSize the size of the buffer Returns: 0 on success -1 on failure -1 on NULL pointers -1 if maxSize is 0 or larger than SSIZE_MAX See also: kdbSetString() and kdbRemove() to set and remove a string kdbGetKey(), keySetKey() to work with Keys kdbGet() and kdbGetByName() for full access to KDB Backends :: Internal Helper for Elektra datastructures int kdbRemove (KDB *handle, const char *keyname) Remove a key by its name from the backend storage. With kdbSetString() its only possible to set a key with an empty string. To really remove a key in a highlevel way you can use this method. Parameters: handle contains internal information of opened key database keyname the name of the key to be removed Returns: 0 on success -1 on failure -1 on NULL pointers See also: together with kdbSetString() and kdbGetString() a highlevel interface for KDB :: Low Level Methods commandRemove() code in KDB :: Low Level Methods command for usage example int kdbSetKey (KDB *handle, const Key *key) Sets key in the backend storage. While kdbSetKey() is perfect for a simple get of a specific key, kdbGet() and kdbGetByName() gives you more control over the keyset. Parameters: handle contains internal information of opened key database key Key to set Returns: 0 on success -1 on failure -1 on NULL pointer See also: kdbGetKey() to get a single Key :: Basic Methods kdbSet() for more control over KeySet :: Class Methods and options commandSet() code in KDB :: Low Level Methods command for usage example int kdbSetString (KDB *handle, const char *keyname, const char *value) A high-level method to set a value to a key, by key name. It will check if key exists first, and keep its metadata. So you'll not loose the previous key comment. This will set a text key. So if the key was previously a binary it will be retyped as string. Parameters: handle contains internal information of opened key database keyname the name of the key to receive the value value the value to be set Returns: 0 on success -1 on NULL pointers -1 on failure See also: kdbGetString(), keySetString(), kdbSetKey() Author Generated automatically by Doxygen for Elektra Projekt from the source code. Elektra Projekt Fri Aug 26 2011 KDB :: High Level methods(3)
All times are GMT -4. The time now is 08:22 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy