Sponsored Content
Top Forums Shell Programming and Scripting sed to replace at fixed location Post 302535996 by asutoshch on Sunday 3rd of July 2011 07:03:53 PM
Old 07-03-2011
sed to replace at fixed location

I have got a text file- each line of 200 characters length. The file is too large in size. It could be 100 MB. The lines begin with any of 0,1,2,3,4,5. I want to replace from 121-131 characters with spaces irrespective of wehatever it is there (the exisitng charatcers could be spaces). And this I want only for the lines starting with 3. Can someone help me how to proceed ?
Code:
1 THIS IS TO EXPLAIN WITH AN EXAMPLE HOW WE PROCESS THE STANDARD FLOW OF DATA SET     1 AAAAAAAAAAAAAAAAABBBBBBBBBBBBBBC  CCCCCCCCCCCDDDDDDDDDDDDDDDDDDDEEEEEEEEEEEEEEEEEEFFFFFFFFFFFFFFfGGGGGGGHHHHEND
0 THIS IS TO EXPLAIN WITH AN EXAMPLE HOW WE PROCESS THE STANDARD FLOW OF DATA SET     1 AAAAAAAAAAAAAAAAABBBBBBBBBBBBBBCCCCCCCCCCCCCCDDDDDDDDDDDDDDDDDDDEEEEEEEEEEEEEEEEEEFFFFFFFFFFFFFFfGGGGGGGHHHHEND
3 THIS IS TO EXPLAIN WITH AN EXAMPLE HOW WE PROCESS THE STANDARD FLOW OF DATA SET     1 AAAAAAAAAAAAAAAAABBBBBBBBBBBBBBCCC     CCCCCCDDDDDDDDDDDDDDDDDDDEEEEEEEEEEEEEEEEEEFFFFFFFFFFFFFFfGGGGGGGHHHHEND
3 THIS IS TO EXPLAIN WITH AN EXAMPLE HOW WE PROCESS THE STANDARD FLOW OF DATA SET     1 AAAAAAAAAAAAAAAAABBBBBBBBBBBBBBCCCCCCCCC 6  CDDDDDDDDDDDDDDDDDDDEEEEEEEEEEEEEEEEEEFFFFFFFFFFFFFFfGGGGGGGHHHHEND
5 THIS IS TO EXPLAIN WITH AN EXAMPLE HOW WE PROCESS THE STANDARD FLOW OF DATA SET     1 AAAAAAAAAAAAAAAAABBBBBBBBBBBBBBCCCCCCCCCCCCCCDDDDDDDDDDDDDDDDDDDEEEEEEEEEEEEEEEEEEFFFFFFFFFFFFFFfGGGGGGGHHHHEND
1 THIS IS TO EXPLAIN WITH AN EXAMPLE HOW WE PROCESS THE STANDARD FLOW OF DATA SET     1 AAAAAAAAAAAAAAAAABBBBBBBBBBBBBBCCCCCCCCCCCCCCDDDDDDDDDDDDDDDDDDDEEEEEEEEEEEEEEEEEEFFFFFFFFFFFFFFfGGGGGGGHHHHEND

Afrer replacing it will look like
Code:
1 THIS IS TO EXPLAIN WITH AN EXAMPLE HOW WE PROCESS THE STANDARD FLOW OF DATA SET     1 AAAAAAAAAAAAAAAAABBBBBBBBBBBBBBC  CCCCCCCCCCCDDDDDDDDDDDDDDDDDDDEEEEEEEEEEEEEEEEEEFFFFFFFFFFFFFFfGGGGGGGHHHHEND
0 THIS IS TO EXPLAIN WITH AN EXAMPLE HOW WE PROCESS THE STANDARD FLOW OF DATA SET     1 AAAAAAAAAAAAAAAAABBBBBBBBBBBBBBCCCCCCCCCCCCCCDDDDDDDDDDDDDDDDDDDEEEEEEEEEEEEEEEEEEFFFFFFFFFFFFFFfGGGGGGGHHHHEND
3 THIS IS TO EXPLAIN WITH AN EXAMPLE HOW WE PROCESS THE STANDARD FLOW OF DATA SET     1 AAAAAAAAAAAAAAAAABBBBBBBBBBBBBBC          CCCDDDDDDDDDDDDDDDDDDDEEEEEEEEEEEEEEEEEEFFFFFFFFFFFFFFfGGGGGGGHHHHEND
3 THIS IS TO EXPLAIN WITH AN EXAMPLE HOW WE PROCESS THE STANDARD FLOW OF DATA SET     1 AAAAAAAAAAAAAAAAABBBBBBBBBBBBBBC            CDDDDDDDDDDDDDDDDDDDEEEEEEEEEEEEEEEEEEFFFFFFFFFFFFFFfGGGGGGGHHHHEND
5 THIS IS TO EXPLAIN WITH AN EXAMPLE HOW WE PROCESS THE STANDARD FLOW OF DATA SET     1 AAAAAAAAAAAAAAAAABBBBBBBBBBBBBBCCCCCCCCCCCCCCDDDDDDDDDDDDDDDDDDDEEEEEEEEEEEEEEEEEEFFFFFFFFFFFFFFfGGGGGGGHHHHEND
1 THIS IS TO EXPLAIN WITH AN EXAMPLE HOW WE PROCESS THE STANDARD FLOW OF DATA SET     1 AAAAAAAAAAAAAAAAABBBBBBBBBBBBBBCCCCCCCCCCCCCCDDDDDDDDDDDDDDDDDDDEEEEEEEEEEEEEEEEEEFFFFFFFFFFFFFFfGGGGGGGHHHHEND

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sed replace with fixed length

$ cat template s.noName $ sed "s/s.no/1/" template > out $ sed "s/s.no/100/" template >>out $ cat out 1Name 100Name 1 Name 100Name (7 Replies)
Discussion started by: McLan
7 Replies

2. Shell Programming and Scripting

Replace fixed strings only

Hi All, I just need to do find and replace in a file.... say for eg I have the input file like below: in.txt ##### oldtextoldtext oldtext oldtext oldtext oldtext123 oldtext- oldtext I need to replace oldtext to newtext... my output file should come like below.. out.txt... (9 Replies)
Discussion started by: askumarece
9 Replies

3. Shell Programming and Scripting

Replace spaces at a specific Location

Hello All, I have a comma separated file which needs to be loaded to the database. But, I need to trim the white spaces for a specific column before its loaded. Below is the sample line from the input file: 690,690,0575,"01011940","01011940", , , , , ,36720,36722,V2020,V2999,... (6 Replies)
Discussion started by: Praveenkulkarni
6 Replies

4. Shell Programming and Scripting

Replace Date in a fixed length file

Hello All, I working on ksh. I am using fixed length file. My file is like: ======== IXTTIV110827 NANTH AM IKSHIT ABCDEF 0617 IJAY NAND EENIG ZXYWVU 0912 AP OOK OONG PQRSTU100923 NASA DISH TTY ASDFG 0223 GHU UMA LAM QWERT 0111 ATHE SH THEW ======= From 7th to 12 is a date... (4 Replies)
Discussion started by: AnanthaDikshit
4 Replies

5. Shell Programming and Scripting

Using sed to replace a word at specific location

I'm try to change a the prohibit to aix for the lines starting with ssh and emagent and rest should be the same. Can anyone please suggest me how to do that using a shell script or sed passwd account required /usr/lib/security/pam_prohibit passwd session required ... (13 Replies)
Discussion started by: pjeedu2247
13 Replies

6. Shell Programming and Scripting

To replace the value of the column in a fixed width file

I have a fixed with file with header & trailer length having the same length of the detail record file. The details record length of this file is 24, for Header and Trailer the records will be padded with spaces to match the record length of the file Currently I am adding 3 spaces in header... (14 Replies)
Discussion started by: ginrkf
14 Replies

7. Shell Programming and Scripting

Deleting lines in a fixed length file where there is a word at specific location

I have a big file having 100 K lines. I have to read each line and see at 356 character position whethere there is a word "W" in it. If it is their then don't delete the line otherwise delete it. There are two lines as one Header and one trailer which should remain same. Can somebody... (5 Replies)
Discussion started by: mohit kanoongo
5 Replies

8. Shell Programming and Scripting

Replace and Increment a value in the fixed length file

Hi Everyone, I need to increment a value in the fixed length file. The file has almost a million rows. Is there any easy way to accomplish this. Ex input file ASDSD ADSD 00000 X AAASD ADSD 00000 X SDDDD ADSD 00000 X Ouput ASDSD ADSD 00001 X AAASD ADSD 00002 X SDDDD ADSD 00003 X ... (7 Replies)
Discussion started by: saratha14
7 Replies

9. Shell Programming and Scripting

Replace using awk on fixed width file.

All, I used to use following command to replace specific location in a fixed width file. Recently looks like my command stopped working as intended. We are on AIX unix. awk 'function repl(s,f,t,v) { return substr(s,1,f-1) sprintf("%-*s", t-f+1, v) substr(s,t+1) } NR<=10 {... (3 Replies)
Discussion started by: pinnacle
3 Replies

10. Shell Programming and Scripting

Replace characters at fixed positions

My objective is to replace the 8th, 9th, 10th characters by 1 space per character (total 3 spaces) in a file. I achieved this using following command: sed 's/\(.\)/\1@/7;s/@\(...\)/ /' FileData.txt > FileData_UPDATED.txt Another situation comes when I need to done same but excluding 1st... (5 Replies)
Discussion started by: manishdivs
5 Replies
EXPLAIN(7)							   SQL Commands 							EXPLAIN(7)

NAME
EXPLAIN - show the execution plan of a statement SYNOPSIS
EXPLAIN [ ANALYZE ] [ VERBOSE ] query INPUTS ANALYZE Flag to carry out the query and show actual run times. VERBOSE Flag to show detailed query plan dump. query Any query. OUTPUTS Query plan Explicit query plan from the PostgreSQL planner. Note: Prior to PostgreSQL 7.3, the query plan was emitted in the form of a NOTICE message. Now it appears as a query result (format- ted like a table with a single text column). DESCRIPTION
This command displays the execution plan that the PostgreSQL planner generates for the supplied query. The execution plan shows how the ta- ble(s) referenced by the query will be scanned---by plain sequential scan, index scan, etc.---and if multiple tables are referenced, what join algorithms will be used to bring together the required tuples from each input table. The most critical part of the display is the estimated query execution cost, which is the planner's guess at how long it will take to run the query (measured in units of disk page fetches). Actually two numbers are shown: the start-up time before the first tuple can be returned, and the total time to return all the tuples. For most queries the total time is what matters, but in contexts such as an EXISTS sub-query the planner will choose the smallest start-up time instead of the smallest total time (since the executor will stop after getting one tuple, anyway). Also, if you limit the number of tuples to return with a LIMIT clause, the planner makes an appropriate interpolation between the endpoint costs to estimate which plan is really the cheapest. The ANALYZE option causes the query to be actually executed, not only planned. The total elapsed time expended within each plan node (in milliseconds) and total number of rows it actually returned are added to the display. This is useful for seeing whether the planner's esti- mates are close to reality. Caution: Keep in mind that the query is actually executed when ANALYZE is used. Although EXPLAIN will discard any output that a SELECT would return, other side-effects of the query will happen as usual. If you wish to use EXPLAIN ANALYZE on an INSERT, UPDATE, or DELETE query without letting the query affect your data, use this approach: BEGIN; EXPLAIN ANALYZE ...; ROLLBACK; The VERBOSE option emits the full internal representation of the plan tree, rather than just a summary. Usually this option is only useful for debugging PostgreSQL. The VERBOSE dump is either pretty-printed or not, depending on the setting of the EXPLAIN_PRETTY_PRINT configura- tion parameter. NOTES There is only sparse documentation on the optimizer's use of cost information in PostgreSQL. Refer to the User's Guide and Programmer's Guide for more information. USAGE
To show a query plan for a simple query on a table with a single int4 column and 10000 rows: EXPLAIN SELECT * FROM foo; QUERY PLAN --------------------------------------------------------- Seq Scan on foo (cost=0.00..155.00 rows=10000 width=4) (1 row) If there is an index and we use a query with an indexable WHERE condition, EXPLAIN will show a different plan: EXPLAIN SELECT * FROM foo WHERE i = 4; QUERY PLAN -------------------------------------------------------------- Index Scan using fi on foo (cost=0.00..5.98 rows=1 width=4) Index Cond: (i = 4) (2 rows) And here is an example of a query plan for a query using an aggregate function: EXPLAIN SELECT sum(i) FROM foo WHERE i < 10; QUERY PLAN --------------------------------------------------------------------- Aggregate (cost=23.93..23.93 rows=1 width=4) -> Index Scan using fi on foo (cost=0.00..23.92 rows=6 width=4) Index Cond: (i < 10) (3 rows) Note that the specific numbers shown, and even the selected query strategy, may vary between PostgreSQL releases due to planner improve- ments. COMPATIBILITY
SQL92 There is no EXPLAIN statement defined in SQL92. SQL - Language Statements 2002-11-22 EXPLAIN(7)
All times are GMT -4. The time now is 09:41 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy