Sponsored Content
Full Discussion: Text processing in UNIX
Top Forums Shell Programming and Scripting Text processing in UNIX Post 303018993 by MadeInGermany on Wednesday 20th of June 2018 06:03:28 PM
Old 06-20-2018
You must delay the printout until the last field changes, and then print the stored values. At the end of the file you must do it once more, therefore a function is appropriate.
Code:
prtout(){
  [[ -n $lastf13 ]] && echo "$key|$out1|$out2|$lastf13"
}

out1=""
out2=""
lastf13=""
while IFS="|" read f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14
do
  if [[ $f13 != $lastf13 ]]
  then
    prtout
    key="$f1|$f2|$f3"
    out1="$f4=$f9"
    out2="$f5=$f10"
    [[ -n $f6 ]] && out2="$out2 and $f6=$f11"
    [[ -n $f7 ]] && out2="$out2 and $f7=$f12"
    lastf13=$f13
  else
    out1="$out1,$f4=$f9"
  fi
done < filename.out
prtout

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Processing a text file

A file contains one name per line, such as: john doe jack bruce nancy smith sam riley When I 'cat' the file, the white space is treated as a new line. For example list=`(cat /path/to/file.txt)` for items in $list do echo $items done I get: john doe (1 Reply)
Discussion started by: TheCrunge
1 Replies

2. UNIX for Dummies Questions & Answers

text file processing

Hello! There is a text file, that contains hierarchy of menues, like: Aaaaa->Bbbbb Aaaaa->Cccc Aaaaa-> {spaces} Ddddd (it means that the full path is Aaaaa->Cccc->Ddddd ) Aaaaa-> {more spaces} Eeeee (it means that the full path is Aaaaa->Cccc->Ddddd->Eeeee ) Fffffff->Ggggg... (1 Reply)
Discussion started by: alias47
1 Replies

3. Shell Programming and Scripting

seeking help in text processing

Hi, I am a newbie in shell scripting. I want to get an expert help in solving a text processing issue. The issue I am facing is that, in the below log file contents I need to extract each block of lines (it could be a single line also) based on some regular expression and store it in... (8 Replies)
Discussion started by: Alecs
8 Replies

4. Shell Programming and Scripting

Text processing of file

I have a text file which is a dataset. and I need to convert it into a CSV format The file is as follows : First line : -1 3:1 11:1 14:1 19:1 39:1 42:1 55:1 64:1 67:1 73:1 75:1 76:1 80:1 83:1 Second line " +1 5:1 11:1 15:1 32:1 39:1 40:1 52:1 63:1 67:1 73:1 74:1 76:1 78:1 83:1 There are a... (6 Replies)
Discussion started by: ajayram
6 Replies

5. Shell Programming and Scripting

Text processing doubt

How to print nth column of a pattern/file without using awk,cut commands? (1 Reply)
Discussion started by: rajkumarin
1 Replies

6. Programming

awk processing / Shell Script Processing to remove columns text file

Hello, I extracted a list of files in a directory with the command ls . However this is not my computer, so the ls functionality has been revamped so that it gives the filesizes in front like this : This is the output of ls command : I stored the output in a file filelist 1.1M... (5 Replies)
Discussion started by: ajayram
5 Replies

7. Shell Programming and Scripting

Text processing using awk

I dispose of two tab-delimited files (the first column is the primary key): File 1 (there are multiple rows sharing the same key, I cannot merge them) A 28,29,30,31 A 17,18,19 B 11,13,14,15 B 8,9File 2 (there is one only row beginning with a given key) A 2,8,18,30,31 B ... (3 Replies)
Discussion started by: dovah
3 Replies

8. Shell Programming and Scripting

Help with text processing

I have an Input file which has a series of lines(which could vary) followed by two blank lines and then another series of lines(Could be any number of lines) followed by two blank lines and then repeats. I need to use filters to convert the following input file(which is an example) to an output... (7 Replies)
Discussion started by: bikerboy
7 Replies

9. Shell Programming and Scripting

Text processing

Hi, Need an advise on $ cat test.txt START field1 field2 field3 field4 field5 field6 END 12345|6|1|2|3|4|111|119 67890|6|1|3|8|9|112|000 $ (4 Replies)
Discussion started by: getmilo
4 Replies

10. Shell Programming and Scripting

awk for text processing

Hi,my file is in this format ", \"symbol\": \"Rbm38\" } ]" I want to convert it to a more user readable format _id pubmed text symbol 67196 18667844 Overexpression of UBE2T in NIH3T3 cells significantly promoted colony formation in mouse cell cultures Ube2t 56190 21764855 ... (3 Replies)
Discussion started by: biofreek
3 Replies
jim_convert(1)						      General Commands Manual						    jim_convert(1)

NAME
jim_convert, jdic2txt, jsy2vjetxt, jsy2wxtxt, txt2jdic, vje2jsytxt, wx2jsytxt - Convert Japanese text and dictionary files between the JSY, WX, and VJE input methods SYNOPSIS
/usr/i18n/bin/jdic2txt [-v] [jsy-dictionary-filename] /usr/i18n/bin/jsy2vjetxt [jsy-text-filename] [vje-text-filename] /usr/i18n/bin/jsy2wxtxt [jsy-text-filename] [wx-text-filename] /usr/i18n/bin/txt2jdic [[-a] jsy-dictionary-filename] /usr/i18n/bin/vje2jsytxt [vje-text-filename] [jsy-text-filename] /usr/i18n/bin/wx2jsytxt [wx-text-filename] [jsy-text-filename] OPTIONS
Prints conversion statistics to stderr. Appends conversion results to an existing dictionary rather than creating a new dictionary. OPERANDS
Specifies the name of a JSY dictionary file. Specifies the name of a text file in JSY format. Specifies the name of the text file in VJE format. Specifies the name of a text file in WX format. DESCRIPTION
Three Japanese input methods are used on a Tru64 UNIX system: the JSY input method (Compaq), the WX input method (A.I. Soft Company), and the VJE input method (VACS Company). Software for the JSY input method is available in optional Tru64 UNIX subsets for Japanese language support. Software for the other two Japanese input methods is included only with the Japanese Tru64 UNIX product that is sold in Japan. Each of these input methods uses a specialized dictionary for conversion between Kana and Kanji characters. This fact makes it difficult for users to migrate their personal dictionaries from one input method to another, or to create a customized dictionary from a text source file for an existing dictionary. The converters described on this reference page help support customization and migration of private user dictionaries for Kana-Kanji conversion. The converters described on this reference page can be used in combination with utilities supplied with third-party software to migrate Kana-Kanji dictionaries from one input method to another. For the jsy2vjetxt, jsy2wxtxt, vje2jsytxt, and wx2jsytxt converters, both file operands are optional. If neither file is specified, stdin and stdout are used as input and output. If only one file is specified, that file is used as input and stdout is used as output. For the jdic2txt converter, stdin is used as input if the dictionary operand is omitted. The conversion results are always sent to stdout. For the txt2jdic converter, stdin is used as input. If the dictionary file argument is omitted, results are sent to stdout. The following diagrams show how the process for text file and dictionary conversion differs, depending on the input method format. In these diagrams, wx3ent and wx31st are utilities packaged with the WX input method software, and vuty is a utility packaged with the VJE input method software. The following diagrams show the process for converting dictionaries to text files using the same input method format: Text file in JSY format -> txt2jdic -> JSY dictionary JSY dictionary -> jdic2txt -> Text file in JSY format Text file in WX format -> wx3ent -> WX dictionary WX dictionary -> wx31st -> Text file in WX format Text file in VJE format -> vuty -> VJE dictionary VJE dictionary -> vuty -> Text file in VJE format The following diagrams show the process for converting text files from one input method format to another: Text file in JSY format -> jsy2wxtxt -> Text file in WX format Text file in JSY format -> jsy2vjetxt -> Text file in VJE format Text file in WX format -> wx2jsytxt -> Text file in JSY format Text file in VJE format -> vje2jsytxt -> Text file in JSY format The following diagrams show the process for converting dictionaries from one input method to another: JSY dict. -> jdic2txt -> jsy2wxtxt -> wx3ent -> WX dict. JSY dict. -> jdic2txt -> jsy2vjetxt -> vuty -> VJE dict. WX dict. -> wx31st -> wx2jsytxt -> txt2jdic -> JSY dict. VJE dict. -> vuty -> vje2jsytxt -> txt2jdic -> JSY dict. FILES
Directory where converters reside. SEE ALSO
Japanese(5) jim_convert(1)
All times are GMT -4. The time now is 04:36 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy