Sponsored Content
Top Forums Shell Programming and Scripting extraction of last but one char Post 302167313 by hidnana on Thursday 14th of February 2008 04:56:19 AM
Old 02-14-2008
extraction of last but one char

I need to extract the character before the last "|" in the following lines, which are 'N' and 'U'. The last "|" shouldn't be extracted. Also the no.s of "|" may vary in a line, but I need only the character before the last one.

TT-CAP-N241485-0005241485|ADMINISTRATOR|INC_ORGANISATION_NAME|SUPERIOR_TITLE_1|REV|FIRST_NAME_1|MIDDLE_NAME_1|SURNA ME_FIELD|INC ADDRESSS 1|INC ADDRESSS 2|INC ADDRESSS 3|INC ADDRESSS 4|INC ADDRESSS 5|INC ADDRESSS 6|IN123EC|MALTA|Y||M||Y|LIFEASSURED 2|Y|N||||||||||||||||||||||||Y||Y||||||||||||PRU|A||289832|||FCBGFBF|Y|Y|1|DC|1|1|3|Y|O||20300601||| CAP|5649369|VVUMU7SMT0|HCBCBFDJF|N|Y|N|Y|Y|N|Y|Y|N|3||6|C|20051205|555555555|||||20070604|4|15||C|0| 9|4527|0||20071109|4|C|982062|23569837|36657407|9096||20071205|1|N|

TT-CAP-5241492-0005241492|ADMINISTRATOR1|INC_ORGANISATION_NAME|SUPERIOR_TITLE_1|MS|FIRST_NAME_1|MIDDLE_NAME_1|SURNA ME_FIELD|INC ADDRESSS 1|INC ADDRESSS 2|INC ADDRESSS 3|INC ADDRESSS 4|INC ADDRESSS 5|INC ADDRESSS 6|IN123EC||N||F||N|LIFE ASSURED 1|Y|N||||||||||||||||||||||||Y||Y||||||||||||PRU|BFF||200006|||EB|Y|Y|3|DC|2|1|3|Y|O||20301207|||CAP |5649376|ZLBFQDGVGIOIJDHKNDK|F|N|Y|Y|N|Y|N|N|Y|N|4||7|C|20051205|555555555|||||20070604|2|1600770||B |281215|66|124002|923545||20060405|1|C|1446100|92811|64148521|5||20071205|1|U|

I'm not able to achieve it by cut command. How can it be done ?

Last edited by hidnana; 02-14-2008 at 06:06 AM..
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

extraction from a tape

Hi, I have a backup on tape which was done by tar by someone else. How can I extract it now ? I know tar -xf for the tar file on disk but for the tar file on a tape, how should I do ? Many thanks before. PS : uname -a AIX server12 5 00545FFA4C00 (4 Replies)
Discussion started by: big123456
4 Replies

2. Shell Programming and Scripting

extraction of last but one char in a line

I need to extract the character before the last "|" in the following lines, which are 'N' and 'U'. The last "|" shouldn't be extracted. Also the no.s of "|" may vary in a line, but I need only the character before the last one. ... (1 Reply)
Discussion started by: hidnana
1 Replies

3. Shell Programming and Scripting

Regex extraction

Hello, I need your help to extract text from following: ./sherg_fyd_rur:blkabl="R23.21_BL2008_0122_1" ./serge_a75:rlwual="/main/r23.21=26-Mar-2008.05:00:20UTC@R11.31_BL2008_0325" ./serge_a75:blkabl="R23.21_BL2008_0325" ./sherg_proto_npiv:bkguals="R23.21_BL2008_0302 I80_11.31_LR" I... (11 Replies)
Discussion started by: abdurrouf
11 Replies

4. Shell Programming and Scripting

How to replace any char with newline char.

Hi, How to replace any character in a file with a newline character using sed .. Ex: To replace ',' with newline Input: abcd,efgh,ijkl,mnop Output: abcd efgh ijkl mnop Thnx in advance. Regards, Sasidhar (5 Replies)
Discussion started by: mightysam
5 Replies

5. Programming

Adding a single char to a char pointer.

Hello, I'm trying to write a method which will return the extension of a file given the file's name, e.g. test.txt should return txt. I'm using C so am limited to char pointers and arrays. Here is the code as I have it: char* getext(char *file) { char *extension; int i, j;... (5 Replies)
Discussion started by: pallak7
5 Replies

6. Programming

concat const char * with char *

hello everybody! i have aproblem! i dont know how to concatenate const char* with char const char *buffer; char *b; sprintf(b,"result.txt"); strcat(buffer,b); thanx in advance (4 Replies)
Discussion started by: nicos
4 Replies

7. Shell Programming and Scripting

how first char in odd line and second char in even line

Hi I m having ifconfig -a o/p like sbanlab1:ksh# ifconfig -a | egrep "flags|inet" | awk -F' ' '{print $1,$2}' lo0: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> inet 127.0.0.1 lo0:1: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> inet 127.0.0.1 bge0:... (1 Reply)
Discussion started by: tarunn.dubeyy
1 Replies

8. Shell Programming and Scripting

extraction

I have following input @xxxxxx@ I want to extract what's between @....@ that is : xxxx using SED command (6 Replies)
Discussion started by: xerox
6 Replies

9. Programming

error: invalid conversion from ‘const char*’ to ‘char*’

Compiling xpp (The X Printing Panel) on SL6 (RHEL6 essentially): xpp.cxx: In constructor ‘printFiles::printFiles(int, char**, int&)’: xpp.cxx:200: error: invalid conversion from ‘const char*’ to ‘char*’ The same error with all c++ constructors - gcc 4.4.4. If anyone can throw any light on... (8 Replies)
Discussion started by: GSO
8 Replies

10. Programming

Invalid conversion from char* to char

Pointers are seeming to get the best of me and I get that error in my program. Here is the code #include <stdio.h> #include <stdlib.h> #include <string.h> #define REPORTHEADING1 " Employee Pay Hours Gross Tax Net\n" #define REPORTHEADING2 " Name ... (1 Reply)
Discussion started by: Plum
1 Replies
UNICONV(8)							   Netatalk 2.2 							UNICONV(8)

NAME
uniconv - convert Netatalk volume encoding SYNOPSIS
uniconv [-ndv] -c cnidbackend -f fromcode -t tocode [-m maccode] volumepath DESCRIPTION
uniconv converts the volume encoding of volumepath from the fromcode to the tocode encoding. OPTIONS
-c CNID backend used on this volume, usually cdb or dbd. Should match the backend selected with afpd for this volume. If not specified, the default CNID backend `dbd' is used -d don't CAP encode leading dots (:2e), equivalent to usedots in AppleVolumes.default(5) -f encoding to convert from, use ASCII for CAP encoded volumes -h display help -m Macintosh client codepage, required for CAP encoded volumes. Defaults to `MAC_ROMAN' -n `dry run', don't do any real changes -t volume encoding to convert to, e.g. UTF8 -v verbose output, use twice for maximum logging. -V print version and exit WARNING
Setting the wrong options might render your data unusable!!! Make sure you know what you are doing. Always backup your data first. It is *strongly* recommended to do a `dry run' first and to check the output for conversion errors. afpd(8) should not be running while you change the volume encoding. Remember to change volcodepage in AppleVolumes.default(5) to the new codepage, before restarting afpd. In case of MacChineseTraditional, MacJapanese or MacKorean, uniconv cannot be used. USE AT YOUR OWN RISK!!! SELECTABLE CHARSETS
Netatalk provides internal support for UTF-8 (pre- and decomposed) and CAP. If you want to use other charsets, they must be provided by iconv(1) uniconv also knows iso-8859.adapted, an old style 1.x NLS widely used. This is only intended for upgrading old volumes, afpd(8) cannot handle iso-8859.adapted anymore. CNID BACKGROUND
The CNID backends maintains name to ID mappings. If you change a filename outside afpd(8) (shell, samba), the CNID db, i.e. the DIDNAME index, gets inconsistent. Netatalk tries to recover from such inconsistencies as gracefully as possible. The mechanisms to resolve such inconsistencies may fail sometimes, though, as this is not an easy task to accomplish. I.e. if several names in the path to the file or directory have changed, things may go wrong. If you change a lot of filenames at once, chances are higher that the afpds fallback mechanisms fail, i.e. files will be assigned new IDs, even though the file hasn't changed. uniconv therefore updates the CNID entry for each file/directory directly after it changes the name to avoid inconsistencies. The two supported backends for volumes, dbd and cdb, use the same CNID db format. Therefore, you could use uniconv with cdb and afpd with dbd later. Warning: There must not be two processes opening the CNID database using different backends at once! If a volume is still opened with dbd (cnid_metad/cnid_dbd) and you start uniconv with cdb, the result will be a corrupted CNID database, as the two backends use different locking schemes. You might run into additional problems, e.g. if dbd is compiled with transactions, cdb will not update the transaction logs. In general, it is recommended to use the same backend for uniconv you are using with afpd(8). EXAMPLES
convert 1.x CAP encoded volume to UTF-8, clients used MacRoman codepage, cnidscheme is dbd: example% uniconv -c dbd -f ASCII -t UTF8 -m MAC_ROMAN /path/to/share convert iso8859-1 volume to UTF-8, cnidscheme is cdb: example% uniconv -c cdb -f ISO-8859-1 -t UTF8 -m MAC_ROMAN /path/to/share convert 1.x volume using iso8859-1 adapted NLS to CAP encoding: example% uniconv -f ISO-8859-ADAPTED -t ASCII -m MAC_ROMAN/path/to/share convert UTF-8 volume to CAP, for MacCyrillic clients: example% uniconv -f UTF8 -t ASCII -m MAC_CYRILLIC /path/to/share SEE ALSO
AppleVolumes.default(5),afpd(8),iconv(1),cnid_metad(8),cnid_dbd(8) Netatalk 2.2 24 Jun 2004 UNICONV(8)
All times are GMT -4. The time now is 10:43 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy