Sponsored Content
Top Forums Shell Programming and Scripting File Splitter output filename Post 302713865 by santosh2k2 on Thursday 11th of October 2012 11:19:06 AM
Old 10-11-2012
My requirement is extended where the file shud always start with 101 type record. The record count should be less that 10. for any section, 104 type records will not go more than 7

So below command splits the file in records of 10 but is not able to make 101 as first record of splitted file. can someone please extend below command.

Code:
awk 'NR%"'"10"'"==1{x="'"${SrcFileName}_"'" sprintf("%03d",++i) ".txt"}{print > x}' $SrcFileName.txt

Sample source file i.e. A.txt file is
Code:
101|M|28854| 
104|28854| I|
101|M|30854| MER
104|30854| S|
104|30854| C|
104|30854| I|
101|M|30855| SG
104|30855| I|
104|30855| S|
104|30855| C|
104|30855| S|
101|M|30856| 
104|30856| I|
104|30856| S|
104|30856| S|
104|30856| S|
104|30856| C|
104|30856| S|
101|M|30857| 
104|30857| I|
104|30857| S|
104|30857| S|
104|30857| S|
104|30857| C|
104|30857| S|


Last edited by santosh2k2; 10-11-2012 at 12:54 PM.. Reason: code tags, please!
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

File splitter by nth row

I need to split a file into n separate files of about the same size. The way the file will be split is at every nth row, starting with the first row, that row will be cut and copied to it's corresponding new file so that each file has unique records. Any 'leftovers' will go into the last file. e.g.... (4 Replies)
Discussion started by: sitney
4 Replies

2. Shell Programming and Scripting

Filename from splitting files to have the same filename of the original file with counter value

Hi all, I have a list of xml file. I need to split the files to a different files when see the <ko> tag. The list of filename are B20090908.1100-20090908.1200_CDMA=1,NO=2,SITE=3.xml B20090908.1200-20090908.1300_CDMA=1,NO=2,SITE=3.xml B20090908.1300-20090908.1400_CDMA=1,NO=2,SITE=3.xml ... (3 Replies)
Discussion started by: natalie23
3 Replies

3. Shell Programming and Scripting

use input filename as an argument to name output file

I know this is a simple matter, but I'm new to this. I have a shell script that calls a sed script from within it. I want the output of the shell script to be based on the input file I pass as an argument to the original script. In other words... ./script.sh file.txt (script.sh calls sed... (2 Replies)
Discussion started by: estebandido
2 Replies

4. Shell Programming and Scripting

Text Splitter

Hi, I need to split files based on text: BEGIN DSJOB Identifier "LA" DateModified "2011-10-28" TimeModified "11.10.02" BEGIN DSRECORD Identifier "ROOT" BEGIN DSSUBRECORD Owner "APT" Name "RecordJobPerformanceData" Value "0" ... (16 Replies)
Discussion started by: unme
16 Replies

5. Shell Programming and Scripting

Source xml file splitter

I have a source file that contains multiple XML files concatenated in it. The separator string between files is <?xml version="1.0" encoding="utf-8"?>. I wanted to split files in multiple files with mentioned names. I had used a awk code earlier to spilt files in number of lines i.e. awk... (10 Replies)
Discussion started by: santosh2k2
10 Replies

6. Shell Programming and Scripting

File splitter

I have below script which does splitting based on a different criteria. can it be amended to produce required result SrcFileName=XML_DUMP awk '/<\?xml version="1\.0" encoding="utf-8"\?>/{n++} n{f="'"${SrcFileName}_"'" sprintf("%04d",n) ".txt" print >> f close(f)}' $SrcFileName.txt My... (3 Replies)
Discussion started by: santosh2k2
3 Replies

7. UNIX for Dummies Questions & Answers

Output a list of five books with their filename titles into one file

Dear unix forum, could I output a list of five books with their file name titles into one file? In order o output all the contents of all the files with their file names there was: find . -type f | while read x; echo -e "\n$x";cat "$x";done > бетховен.txt In spite of them being successively... (5 Replies)
Discussion started by: Xcislav
5 Replies

8. Shell Programming and Scripting

How to remove filename from output file?

Hello, I am trying to print searched multiple keywords in multiple files. It is almost okay with the code but the code puts filename in front of each line. How may I get rid of it? -grep -A1 'word1' *.txt | grep -A1 'word2' | grep -A1 'word3' I expect: Real outcome: How may I... (3 Replies)
Discussion started by: baris35
3 Replies

9. UNIX for Beginners Questions & Answers

Insert the line number from text file to filename output

Hi everyone :) I have a file "words.txt" containing hundreds of lines of text. Each line contains a slogan. Using the code below i am able to generate an image with the slogan text from each line. The image filename is saved matching the last word on each line. Example: Line 1: We do... (2 Replies)
Discussion started by: martinsmith
2 Replies

10. Web Development

Filename output in curl

How can I get the name of the default output filename from curl using the argument -O? Using -o one can choose a filename. I want to get the name of the original file, but don't understand how to get it. curl -o filename http://www.website.com curl -O http://www.website.com The... (3 Replies)
Discussion started by: locoroco
3 Replies
CINTERNET(1)							      SMPPPD							      CINTERNET(1)

NAME
cinternet - simple frontend for smpppd DESCRIPTION
cinternet is a simple frontend for the smpppd. OPTIONS
These options are recognized by cinternet. If a long option shows an argument as mandatory, then it is mandatory for the equivalent short option also. The order of the options is relevant except for the --verbose, --only-local, --version and --help options. -I, --interface-list List all configured interfaces of the smpppd. The interfaces are also marked either with `u' or `d' for their status of up or down respectively. The interface names are utf-8 encoded. -i, --interface-name=NAME Specify a interface. A interface must be specified for most of the options below. This option must be given before any option that requires an interface. The name must exactly match one of the interface list. --interface-number=NUM Specify a interface. A interface must be specified for most of the options below. This option must be given before any option that requires an interface. The numbers start at one. -P, --provider-list List all configured providers for the specified interface. The currently active provider is prefixed by a `a', all others by a `i'. The provider names are utf-8 encoded. -p, --provider-name=NAME Select the active provider for the specified interface by name. The name must exactly match one of the provider list. Only works when the interface is down. --provider-number=NUM Select the active provider for the specified interface by number. The numbers start at one. Only works when the interface is down. -A, --start Start the specified interface. -D, --dialin Trigger dialin for the specified interface. The interface must be in dial on demand mode and already started. Not implemented for all connection types. -H, --hangup Trigger hangup for the specified interface. The interface must be in dial on demand mode. Not implemented for all connection types. -O, --stop Stop the specified interface. --add-link Add a link to a multi-link connection. --remove-link Remove a link from a multi-link connection. -s, --status Display the status of the specified interface. -c, --config Display the configuration of the specified interface. -l, --log Displays the log of the specified interface. -d, --debug={on,off} Turn debugging mode of the smpppd on or off. This does not affect connections already up. -L, --main-config List the main config of the smpppd. -L, --main-log List the main log, the log containing general informations not specific to an interface, of the smpppd. -v, --verbose Be more verbose. -o, --only-local Only connect to local smpppd. --script[=STYLE] Format output for script. Known styles are c and sh. --version Show program version and exit. --help Show help information and exit. WIRELESS LAN OPTIONS
The following commands are only valid if the specified interface is a wireless LAN device. --set-essid=ESSID Set ESSID (network name). --set-bitrate=BITRATE Set a specific bitrate (in Mbps units). Use auto or 0 to switch to automatic mode. --set-wep=KEY Enables WEP encryption for the specified interface. KEY can have different formats, see --keytype for more information. --scan Prints scan results, i.e. access points known to the driver. Note that this does not trigger an active scan. --rescan Triggers an active scan and prints the scan results. Note that this can interrupt exiting connections for a while. --keytype={hex,ascii,hash[40,104]} Sets key type for --set-wep command. hex means the key is given has hex digits. You need to enter exactly the amount of digits needed for the key (e.g. 10 hex digits for 40 bit key, 26 hex digits for 104 bit key, etc). ascii means that the ASCII values of the specified string from the key. You need to enter 5 characters for 40 bit keys, 13 for 104 bit keys, etc. And finally hash means the specified key is used as a passphrase to generate a hash from it, which will be the actual WEP key. Append 40 to hash if you want a 40 bit key generated, and 104 if you want 104 bit (aka 64 and 128 bit, depends on whether you count the initialization vector or not). If the appendix is omitted, 104 bit gets assumed. --authmode={open,shared} This option has to be used together with the --set-wep command. It specifies the authentication mode to be used. open means no explicit authentication (this does not neccessarily mean no encryption). shared means shared key authentication. This authentica- tion mode makes your WEP key more attackable, so do not use it if you don't have to. --connection-status Prints some information about your wireless LAN connection status. FILES
/etc/smpppd-c.conf Contains information about remote smpppd. /var/run/smpppd/control Socket to communicate with local smpppd. SEE ALSO
kinternet, qinternet, accounting(1), smpppd-c.conf(5), smpppd(8), smpppd-ifcfg(8). AUTHOR
Arvin Schnell <arvin@suse.de> SuSE December 2002 CINTERNET(1)
All times are GMT -4. The time now is 09:32 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy