Sponsored Content
Full Discussion: Text processing in UNIX
Top Forums Shell Programming and Scripting Text processing in UNIX Post 303019006 by MadeInGermany on Thursday 21st of June 2018 03:46:09 AM
Old 06-21-2018
The shell has the advantage that you can easily boost it with external commands.
If this is not intended, it is ideal for awk (using its loop over lines with automatic field splitting)
Code:
# shell code with embeded awk 'script'
awk '
  BEGIN { FS=OFS="|" }
# the FS is the field delimiter for the input
# the OSF is for the print command
  function prtout(){
    if (lastf13!="") print key,out1,out2,lastf13
  }
# main loop
  {
    if ($13!=lastf13) {
      prtout()
      key=($1 FS $2 FS $3)
      out1=($4 "=" $9)
      out2=($5 "=" $10)
      if ($6!="") out2=(out2 " and " $6 "=" $11)
      if ($7!="") out2=(out2 " and " $7 "=" $12)
      lastf13=$13
    } else {
      out1=(out1 "," $4 "=" $9)
    }
  }
  END { prtout() }
' < filename.out

 

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
Execute(4)						     Kernel Interfaces Manual							Execute(4)

NAME
Execute - Contains instructions for running commands that require the resources of a remote system SYNOPSIS
/usr/spool/uucp/SystemName/X.RemoteSystemNxxxx DESCRIPTION
The Execute (X.*) files contain instructions for running uucp commands that require the resources of a remote system. They are created by the uux command. The full pathname of a uux command execute file is a form of the following: /usr/spool/uucp/SystemName/X.RemoteSystem- Nxxxx where the SystemName directory is named for the local computer and the RemoteSystem directory is named for the remote system. The N char- acter represents the grade of the work, and the xxxx notation is the 4-digit hexadecimal transfer-sequence number; for example, X.zeusN2121. Note that the grade of the work specifies when the file is to be transmitted during a particular connection. The grade notation is a sin- gle number (0 to 9) or letter (A to Z, a to z). Lower sequence characters cause the file to be transmitted earlier in the connection than do higher sequence characters. The number 0 (zero) is the highest grade, signifying the earliest transmittal; z is the lowest grade, sig- nifying the latest transmittal. The default grade is N. Standard Entries in an Execute File An execute file consists of several lines, each with an identification character and one or more entries: Format and Description U UserName SystemName Specifies the login name of the user issuing the uux command and the name of the system from which the command was issued. N or Z Indicates the error status. The N character means that a failure message is not sent to the user issuing the uux command if the specified command does not exe- cute successfully on the remote system. The Z character means that a failure message is sent to the user issuing the uux command if the specified command does not execute successfully on the remote system. R UserName Specifies the login ID of the user requesting the remote command execution. F FileName Contains the names of the files required to execute the specified command on the remote system. The FileName parameter can be either the complete pathname of the file, including the unique transmission name assigned by the uucp program, or simply the trans- mission name without any path information. The Required File Line can contain zero or more filenames. The uuxqt daemon checks for the existence of all listed files before running the specified command. I FileName Specifies the standard input to be used. The standard input is either specified by a < (less than) symbol in the command string, or is inherited from the standard input of the uux command if that command was issued with the - (dash) flag. If standard input is specified, it also is listed in an F (Required File) line. If standard input is not specified, the uucp program uses the /dev/null device file. O FileName SystemName Specifies the names of the file and system that are to receive standard output from the execution of the command. Standard output is specified by a > (greater than) symbol within the command string. (The >> sequence is not valid in uux commands.) As was the case with standard input, if standard output is not specified, the uucp program uses the /dev/null device file. C CommandString This is the command string that the user requests to be run on the specified system. The uucp program checks the /usr/lib/uucp/Per- missions file on the designated computer to see whether the login ID can run the command on that system. All required files go to the execute file directory, usually /usr/spool/uucp/.Xqtdir. After execution, the standard output is sent to the requested location EXAMPLES
User fong on local system zeus enters the following command: uux - "diff /u/fong/out hera!/u/fong/out2 > ~uucp/DF" This invokes the uux command to run a diff command on the local system, comparing file /u/fong/out with file /u/fong/out2, which is stored on remote system hera. The output of the comparison is placed in the DF file in the public directory on the local system. This command produced the /usr/spool/uucp/hera/X.zeusN212F execute file, which contains the following information: U fong zeus # return status on failure Z # return address for status or input return R fong F /usr/spool/uucp/hera/D.herale954fd out2 O ~uucp/DF zeus C diff /u/fong/out out2 The user line identifies user fong on system zeus. The error status line indicates that fong will receive a failure status message if the diff command fails to execute. The requester is fong, and the file required to execute the command is the following data file: /usr/spool/uucp/hera/D.herale954fd out2 The output of the command is to be written to the public directory on system zeus with the filename DF. (Remember that ~uucp is the shorthand way of specifying the public directory.) The final line is the command string that user fong entered with the uux command. The following is another example of an execute file: U uucp hera # don't return status on failure N # return address for status or input return R uucp F D.hera5eb7f7b I D.hera5eb7f7b C rmail fong This indicates that user uucp on system hera is sending mail to user fong, who is also working on system hera. FILES
Describes access permissions for remote systems Describes accessible remote systems Contains uucp command, data, and execute files Contain instructions for transfers Contains lists of commands that remote systems are permitted to execute Contains files that have been trans- ferred RELATED INFORMATION
Daemons: uuxqt Commands: diff(1), uux(1) delim off Execute(4)
All times are GMT -4. The time now is 05:09 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy