Sponsored Content
Top Forums Shell Programming and Scripting A command to split a file into two based on a string Post 302833723 by tukuyomi on Wednesday 17th of July 2013 05:03:25 PM
Old 07-17-2013
I suspect your RAW file to have \r\n at the end of each line (typically all txt files created from MS Windows notepad). You have to remove \r from the original file. Try (not tested)
Code:
tr '\r\n' '\n' RAW > RAW.1

and retry the awk script with RAW1
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to split the String based on condition?

hi , I have a String str="/opt/ibm/lotus/ibw/latest" or ="/opt/lotus/ibw/latest" this value is dynamic..I want to split this string into 2 strings 1. /opt/ibm/lotus(/opt/lotus) this string must ends with "lotus" 2./ibw/latest can any body help me on this? Regards, sankar (2 Replies)
Discussion started by: sankar reddy
2 Replies

2. Shell Programming and Scripting

bash: How to split up a file based on another?

I've got these 2 files, FILE.txt and SPLIT_BY.txt: FILE.txt contents: FILE01 FILE02 FILE03 FILE04 FILE05 FILE06 FILE07 FILE08 FILE09 FILE10 FILE11 FILE12 FILE13 FILE14 FILE15SPLIT_BY.txt contents: 2 5 (4 Replies)
Discussion started by: byte711
4 Replies

3. Shell Programming and Scripting

AWK Command parse a file based on string.

AWK Command parse a file based on string. I am trying to write a shell script to parse a file based on a string and move the content of the file to another file. Here is scenario. File content below Mime-Version: 1.0 Content-Type: multipart/mixed; ... (2 Replies)
Discussion started by: aakishore
2 Replies

4. Shell Programming and Scripting

Split file based on size

Hi Friends, Below is my requirement. I have a file with the below structure. 0001A1.... 0001B1.. .... 0001L1 0002A1 0002B1 ...... 0002L1 .. the first 4 characters are the sequence numbers for a record, A record will start with A1 and end with L1 with same sequence number. Now the... (2 Replies)
Discussion started by: diva_thilak
2 Replies

5. UNIX for Dummies Questions & Answers

Command to split the files based on the number of lines in it

Hello Friends, Can anyone help me for the below requirement. I am having a file called Input.txt. My requirement is first check the count that is wc -l input.txt If the result of the wc -l Input.txt is less than 10 then don't split the Input.txt file. Where as if Input.txt >= 10 the split... (12 Replies)
Discussion started by: malaya kumar
12 Replies

6. Shell Programming and Scripting

sed or awk command to replace a string pattern with another string based on position of this string

here is what i want to achieve... consider a file contains below contents. the file size is large about 60mb cat dump.sql INSERT INTO `table1` (`id`, `action`, `date`, `descrip`, `lastModified`) VALUES (1,'Change','2011-05-05 00:00:00','Account Updated','2012-02-10... (10 Replies)
Discussion started by: vivek d r
10 Replies

7. Shell Programming and Scripting

KSH: Split String into smaller substrings based on count

KSH HP-SOL-Lin Cannot use xAWK I have several strings that are quite long and i want to break them down into smaller substrings. What I have String = "word1 word2 word3 word4 .....wordx" What I want String1="word1 word2" String2="word 3 word4" String3="word4 word5" Stringx="wordx... (5 Replies)
Discussion started by: nitrobass24
5 Replies

8. Shell Programming and Scripting

Split file based on records

I have to split a file based on number of lines and the below command works fine: split -l 2 Inputfile -d OutputfileMy input file contains header, detail and trailor info as below: H D D D D TMy split files for the above command contains: First File: H DSecond File: ... (11 Replies)
Discussion started by: Ajay Venkatesan
11 Replies

9. Shell Programming and Scripting

How to Split File based on String?

hi , The scenario is like this, i have a large text files (max 5MB , about 5000 file per day ), Inside almost each line of this file there is a tag 3100.2.22.1 (represent Call_Type) , i need to generate many filess , each one with distinct (3100.2.22.1 Call_Type ) , and one more file to... (3 Replies)
Discussion started by: OTNA
3 Replies

10. Shell Programming and Scripting

Split File based on different conditions

I need to split the file Conditions: Ignore any record that either starts with 1 or 9 Split the file at position 404 , if position 404 is abc or def then write all the records in a file > File 1 , the remaining records should go in to a file > File 2 Further I want to split the... (7 Replies)
Discussion started by: protech
7 Replies
gd_delete(3)							      GETDATA							      gd_delete(3)

NAME
gd_delete -- remove a field from a dirfile SYNOPSIS
#include <getdata.h> int gd_delete(DIRFILE *dirfile, const char *field_code, int flags); DESCRIPTION
The gd_delete() function attempts to delete the field specified by field_code in the dirfile specified by dirfile. The field_code should not contain a representation suffix. The flags argument influences how the deletion attempt occurs. It may be zero, for the default behaviour, or else one or more of the fol- lowing flags, bitwise or'd together: GD_DEL_DATA If the field to be deleted is a RAW field, also delete the binary data file associated with it. If field_code specified a RAW field and this flag is not specified, the field will still be deleted but the binary file will be left untouched. GD_DEL_DEREF If the field to be deleted is a CONST or CARRAY field which is used as a parameter in the specification of other fields, resolve these other fields dependence on the deleted field by replacing instances of field_code in their field specifications with the val- ue of the scalar field. GD_DEL_FORCE Delete the indicated field, even if it is used in the specification of other fields, either as a input for a derived vector field or as a scalar parameter in a field specification. GD_DEL_META If the field to be deleted has metafields attached to it, attempt to delete those, too. If the field has metafields and this flag is not specified, the call will fail with the GD_E_DELETE error. RETURN VALUE
On successful deletion, zero is returned. On error, -1 is returned and the dirfile error is set to a non-zero error value. Possible error values are: GD_E_ACCMODE The specified dirfile was opened read-only. GD_E_ALLOC The library was unable to allocate memory. GD_E_BAD_CODE The field specified by field_code was not found in the database. GD_E_BAD_DIRFILE The supplied dirfile was invalid. GD_E_DELETE The attempt to delete the field failed. Either the specified field is used in the specification of other fields and GD_DEL_FORCE or GD_DEL_DEREF was not specified, or it has metafields and GD_DEL_META was not specified. GD_E_INTERNAL_ERROR An internal error occurred in the library while trying to perform the task. This indicates a bug in the library. Please report the incident to the GetData developers. GD_E_PROTECTED The metadata of the fragment containing the field was protected from change. Or, the deletion of the binary data file associated with a RAW field was attempted and the data of the fragment was protected. GD_E_RAW_IO An error occurred while trying to close or delete the binary file associated with a RAW field. GD_E_UNKNOWN_ENCODING The GD_DEL_DATA flag was given but the encoding scheme of the indicated format specification fragment is not known to the library. As a result, the library was unable to delete the binary file associated with a RAW field. GD_E_UNSUPPORTED The GD_DEL_DATA flag was given but the encoding scheme of the indicated format specification fragment does not support deleting the binary file associated with a RAW field. The dirfile error may be retrieved by calling gd_error(3). A descriptive error string for the last error encountered can be obtained from a call to gd_error_string(3). SEE ALSO
gd_open(3), gd_close(3), gd_error(3), gd_error_string(3), gd_metaflush(3) Version 0.7.0 3 November 2010 gd_delete(3)
All times are GMT -4. The time now is 08:54 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy