Sponsored Content
Full Discussion: Conditional Split
Top Forums UNIX for Beginners Questions & Answers Conditional Split Post 303016536 by RudiC on Saturday 28th of April 2018 02:12:00 PM
Old 04-28-2018
OK - I can't see how you call the script. Try
Code:
awk '
NR == 1         {HD = $0
                 next
                }
                {SFX = substr ($0, 31, 3)
                 FN  = FILENAME "_" SFX
                 if (SFX == "000") next
                }

!(FN in CNT)    {print HD > FN
                }
                {print > FN
                 CNT[FN]++
                }
END             {for (FN in CNT)        {print > FN
                                         close (FN)
                                         print "mv " FN " " FN "_" CNT[FN]
                                        }
                }
' file | sh

and adapt to your needs.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

conditional split

Hi, Can someone let me know how I can split a record when it contains a vairable length of fields. Line1 field1,field101,field102,field 103,field104 Line 2 field1,field101,field102,field 103,field104,field201,field202,field 203,field204 Line 3 field1,field101,field102,field... (5 Replies)
Discussion started by: braindrain
5 Replies

2. UNIX for Dummies Questions & Answers

Split a file with no pattern -- Split, Csplit, Awk

I have gone through all the threads in the forum and tested out different things. I am trying to split a 3GB file into multiple files. Some files are even larger than this. For example: split -l 3000000 filename.txt This is very slow and it splits the file with 3 million records in each... (10 Replies)
Discussion started by: madhunk
10 Replies

3. Shell Programming and Scripting

Conditional FTP

Hi Have a Nice Day i m stuck with this quite easy task assume that i m in certain directory and i open a ftp connection from there to some other directory and in second directory there are like so many files from july 02 till today what would be the simple unix command to ftp all files from this... (2 Replies)
Discussion started by: Dastard
2 Replies

4. UNIX for Dummies Questions & Answers

conditional

conditional is not wworking can any one figure out what goes wrong xx1=`$ORACLE_HOME/bin/sqlplus -s apps/ostgapps1 2>/dev/null << EOF WHENEVER SQLERROR EXIT 1 set head off feedback off ; WHENEVER SQLERROR EXIT SQL.SQLCODE; select count(*) from CMS_INVOICE_ALL... (2 Replies)
Discussion started by: u263066
2 Replies

5. UNIX for Dummies Questions & Answers

If conditional

Hi, I am new to unix and shell scripting.In my script,there is a line using the "if" conditional - if && ; then do something Here "x" is a variable holding string value.If it is not equal to a comma or a string,only then I want to enter the "if" loop. But I am getting error while... (1 Reply)
Discussion started by: abhinavsinha
1 Replies

6. Shell Programming and Scripting

If conditional

Hi, I am new to unix and shell scripting.In my script,there is a line using the "if" conditional - if && ; then do something Here "x" is a variable holding string value.If it is not equal to a comma or a string,only then I want to enter the "if" loop. But I am getting error while... (12 Replies)
Discussion started by: abhinavsinha
12 Replies

7. Shell Programming and Scripting

Conditional variables

if {-a file} if {-s file} what it will do if {-z string} what it will do please help on this (1 Reply)
Discussion started by: thelakbe
1 Replies

8. Shell Programming and Scripting

awk to split one field and print the last two fields within the split part.

Hello; I have a file consists of 4 columns separated by tab. The problem is the third fields. Some of the them are very long but can be split by the vertical bar "|". Also some of them do not contain the string "UniProt", but I could ignore it at this moment, and sort the file afterwards. Here is... (5 Replies)
Discussion started by: yifangt
5 Replies

9. Shell Programming and Scripting

awk to format file with conditional split

In the awk below I am splitting $7 on the : (colon) then - (hyphen) as array a. The word chr is printed at the start of every $1 line. Next, $4 is split on the > (greater then) as array b. I am not sure how to account for the two other possibilities in $4 so the correct output is printed. Every... (3 Replies)
Discussion started by: cmccabe
3 Replies

10. UNIX for Beginners Questions & Answers

Split and Rename Split Files

Hello, I need to split a file by number of records and rename each split file with actual filename pre-pended with 3 digit split number. What I have tried is the below command with 2 digit numeric value split -l 3 -d abc.txt F (# Will Produce split Files as F00 F01 F02) How to produce... (19 Replies)
Discussion started by: techedipro
19 Replies
GNUNET-RSA(1)						      General Commands Manual						     GNUNET-RSA(1)

NAME
gnunet-rsa - manipulate GNUnet RSA key files SYNOPSIS
gnunet-rsa [options]FILENAME DESCRIPTION
gnunet-rsa can be used to create an RSA private key and to print the corresponding public key. You must specify a filename containing an RSA private key in GNUnet format as an argument. If the file does not exist, gnunet-rsa will create a key. This may then take a while. If the option -p is given, the corresponding public key will be printed to the console. OPTIONS
-p, --print-public-key Print the corresponding public key to stdout. -P, --print-peer-identity Print the corresponding peer identity (hash of the public key) to stdout. This hash is used for the name of peers. -s, --print-short-identity Print the corresponding short hash (256-bit hash of the public key) to stdout. This hash is used for names in the zkey zone. -c FILENAME, --config=FILENAME Use the configuration file FILENAME. -h, --help Print short help on options. -L LOGLEVEL, --loglevel=LOGLEVEL Use LOGLEVEL for logging. Valid values are DEBUG, INFO, WARNING and ERROR. -v, --version Print GNUnet version number. BUGS
Report bugs by using Mantis <https://gnunet.org/bugs/> or by sending electronic mail to <gnunet-developers@gnu.org> GNUnet Mar 15, 2012 GNUNET-RSA(1)
All times are GMT -4. The time now is 12:45 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy