This looks like it should work to me. Have you tested it? I don't think you need the echo "$line" | grep. If using ksh93 or bash 4 you could write:
Andrew
I have a pipe delimited input file as below. First byte of the each line indicate the record type. Then i need to split the file based on record_type = null,0,1,2,6 and create 5 files. How do i do this in a ksh script? Pls help
|sl||SL|SL|SL|1996/04/03|1988/09/15|C|A|sl||||*|... (4 Replies)
Hi
I am trying to retrieve values from a tab-delimited file.I am using
while read record
value=`echo $record | cut -f12`
done
Where 12 is the column no i want retieve and record is one line of the file.
But it is returning the full record.
Plz help (4 Replies)
Hi, I am looking for a unix command which inserts double quotes around all values in a delimited file. For example,
Input File
153665031,abc,abc ,abc
131278839,def,def ,dec
179821481,efg,efg ,lmn ... (6 Replies)
I would like to use a variable to store the IDs that I would like to extract.
I would like to extract a list of values of the IDs from a delimited string. Using bash here.
file format would be
id1=we1;id2=er2;id3=rt3;id4=yu4
The number of fields and records is not fixed. There could be... (2 Replies)
this is Korn shell unix.
The scenario is I have a pipe delimited text file which needs to be customized. say for example,I have a pipe delimited text file with 15 columns(| delimited) and 200 rows. currently the 11th and 12th column has null values for all the records(there are other null columns... (4 Replies)
Hi
I have a large text file and I want to split its content into multiple flies.
this large file contains several blocks of codes separated by a comment line for each block.
this comment line represents a directory path
So, when separate these blocks each into a separate file, This output... (7 Replies)
This could be a really dummy question.
I have a log text file.
What unix command to extract line from specific string to another specific string.
Is it something similar to?:
more +/"string" file_name
Thanks (4 Replies)
Hi,
Anyone can help, I have a large textfile (one file), and I need to split into multiple file to break each file into ^L.
My textfile
==========
abc company
abc address
abc contact
^L
my company
my address
my contact
my skills
^L
your company
your address
========== (3 Replies)
HI
I want to split file base on tag name.
I have few header and footer on file
<?xml version="1.33" encing="UTF-8"?>
<bulkCmConfigDataFile"
<xn:SubNetwork id="ONRM_ROOT">
<xn:MeContext id="PPP04156">
... (4 Replies)
Hello,
I need to split a pipe de-limited file based on the COLUMN 7 value . If the column value changes I need to split the file
Source File
Payment|ID|DATE|TIME|CONTROLNUMBER|NUMBER|NAME|INDICATOR
42156974|1137937|10/1/2018|104440|4232|2054391|CARE|1... (9 Replies)
Discussion started by: rosebud123
9 Replies
LEARN ABOUT OSX
split
split(n) Tcl Built-In Commands split(n)
__________________________________________________________________________________________________________________________________________________NAME
split - Split a string into a proper Tcl list
SYNOPSIS
split string ?splitChars?
_________________________________________________________________DESCRIPTION
Returns a list created by splitting string at each character that is in the splitChars argument. Each element of the result list will con-
sist of the characters from string that lie between instances of the characters in splitChars. Empty list elements will be generated if
string contains adjacent characters in splitChars, or if the first or last character of string is in splitChars. If splitChars is an empty
string then each character of string becomes a separate element of the result list. SplitChars defaults to the standard white-space char-
acters.
EXAMPLES
Divide up a USENET group name into its hierarchical components:
split "comp.lang.tcl.announce" .
-> comp lang tcl announce
See how the split command splits on every character in splitChars, which can result in information loss if you are not careful:
split "alpha beta gamma" "temp"
-> al {ha b} {} {a ga} {} a
Extract the list words from a string that is not a well-formed list:
split "Example with {unbalanced brace character"
-> Example with {unbalanced brace character
Split a string into its constituent characters
split "Hello world" {}
-> H e l l o { } w o r l d
PARSING RECORD-ORIENTED FILES
Parse a Unix /etc/passwd file, which consists of one entry per line, with each line consisting of a colon-separated list of fields:
## Read the file
set fid [open /etc/passwd]
set content [read $fid]
close $fid
## Split into records on newlines
set records [split $content "
"]
## Iterate over the records
foreach rec $records {
## Split into fields on colons
set fields [split $rec ":"]
## Assign fields to variables and print some out...
lassign $fields
userName password uid grp longName homeDir shell
puts "$longName uses [file tail $shell] for a login shell"
}
SEE ALSO
join(n), list(n), string(n)
KEYWORDS
list, split, string
Tcl split(n)