09-26-2007
Spliting the line based on position.
i want to split a big line based on the position.
example :
I have a single line which has 2300 characters.
i want to split from 1 character to 300th characters as first line
and 301th to 600 as second line and 601th to 900 as third line ...till the end of the string.
Can anyone help on this..
9 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi all;
I'm having headache on append one line to another based on the fix position.Hope u guys can help.
All i need to do is append the line that start with '3' to a line which start with '1' and the position for line 3 that i need to append is 22.
The original file look like this:
... (2 Replies)
Discussion started by: ashikin_8119
2 Replies
2. Shell Programming and Scripting
Hi,
I have a comma separated file with millions of records in it.
I have a requirement to split the file based on the value in a one of the columns.
Suppose i have a text file with columns like C1, C2,C3,C4
Column C4 can hold the values either 01 or 02 03 or 04.
I nned to extract... (2 Replies)
Discussion started by: Raamc
2 Replies
3. Shell Programming and Scripting
Hi,
I have a file with data like below
a}hasksd09090}kdkdkd
aksdkdkdk787}08ksapodd
asl}alks13233}dsjskdkd
I need to replace any '}' to 0 if it appears in 10 to 15 postions.If } appears in any other postion I need to leave it.
So for the above data , output should be
a}hasksd090900kdkdkd... (1 Reply)
Discussion started by: dncs
1 Replies
4. Shell Programming and Scripting
Hi all,
i have file that looks like as below
2263881188,24570896,439,SOLO,SOLO_UNBEATABLE,E,+3.13,+0.00
2263881964,24339077,439,SOLO,SOLO_UNBEATABLE,F,-0.67,+0.00
2263883220,22619162,228,Bell,Bell_MONTHLY,E,-2.04,+0.00
2263883220,22619162,228,Bell,Bell_MONTHLY,F,-2.04,+0.00... (3 Replies)
Discussion started by: raghavendra.cse
3 Replies
5. UNIX for Dummies Questions & Answers
Trying to use sed - but having no luck.
I have a text file - I want to replace whatever character is in position 106, 157 and 237 w/ the string "xxx". Want this change for all lines w/in that text file.
I'm open to using awk or whatever command would be best for replacing characters based... (5 Replies)
Discussion started by: svn
5 Replies
6. Shell Programming and Scripting
The file has record length 200. And i have 100 search strings which are ten digits of character from 1 to 10 characters all of them are unique, they need to searched in a file. Please help me to pull the records based on position (say from 1-10).
test data
1FAHP2DW0BG115206RASHEED ... (6 Replies)
Discussion started by: zooby
6 Replies
7. Shell Programming and Scripting
Hi ,
I have a text file like below
abcd2223232321212121324343
asdsfffhfgfgfhgfhghghghghghgh
dfdfdfgfghfgfgfgfgfgghghghghgh
dfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdf
1234567890sasasasfdfbffghffhf
abcd222323232121212abcdsds
in the above file i need to grep and print the lines if 14th to 18th... (4 Replies)
Discussion started by: aravindj80
4 Replies
8. Shell Programming and Scripting
Hi,
I have a file with multiple lines(fixed width dat file). I want to search for '02' in the positions 45-46 and if available, in that lines, I need to replace value in position 359 with blank. As I am new to unix, I am not able to figure out how to do this. Can you please help me to achieve... (9 Replies)
Discussion started by: Pradhikshan
9 Replies
9. UNIX for Beginners Questions & Answers
Hi Guys,
I have a file which contains multiple lines. I need to split each line 255 characters and then I need to add call statement in the front and semi colon at the end.
I/P:
call sp_rebuildindex('aaa.aaa','column column column column column column column column column column ... (4 Replies)
Discussion started by: Booo
4 Replies
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)