i want to ask how to delete character on specific position in line, lets say i want to remove 5 character from position 1000, so characters from position 1000-1005 will be deleted.
i found this sed command can delete 4 characters from position 10, but i dont know if bigger position or more characters to be delete is needed.
btw i'm using HP-UX
Similar questions have already been asked and answered here. Right at the bottom on this thread you'll find these threads.
Check ...
Let us know if you could adjust it for your requirement or if you need further help
Quote:
Originally Posted by pilnet101
If you are using bash, there is no need to call any external tools to perform this. You can use parameter expansion alone as per below:
hi thanks for the replies,
i find this will work (im not at hp-ux environment at the moment, so i try on ubuntu server)
what if file contain more than 2 millions line is still fine if i do above command ?
You're on the right track. The file size or amount of lines should not matter, imho.
The sed command you mentioned will not work. Here's a fix:
Following is even better, just in case, because it means read the first 4031 characters explicitly from the beginning of the line:
Note that the cut command you've posted will delete only 6 characters. To act same as the above sed command it should be:
No matter which command you run, I suggest to test it with only few records of the real data (before you process the whole file) to ensure the output is as expected:
Hope this helps.
This User Gave Thanks to junior-helper For This Post:
Although both sed and cut work on Ubuntu, the standards only require sed to work on text files. Files with lines containing more than 2048 bytes are not text files on HP-UX. The cut utility, however, is required to work on files with arbitrary line lengths; so it should work on any system.
As RudiC said for sed, the number of lines being processed doesn't matter; both cut and sed work on one line at a time; they don't need to read the whole file into memory at once to do this job.
This User Gave Thanks to Don Cragun For This Post:
I will appreciate if you help me here in this script in Solaris Enviroment.
Scenario:
i have 2 files :
1) /tmp/TRANSACTIONS_DAILY_20180730.txt:
201807300000000004
201807300000000005
201807300000000006
201807300000000007
201807300000000008
2)... (10 Replies)
Discussion started by: teokon90
10 Replies
2. Post Here to Contact Site Administrators and Moderators
In file, we have millions of records each of 1000 in length. And at specific position say 800 there is a space, we need to replace it with Character X if the ID in that row starts with 123.
So far i have used the below which is replacing space at that position to X but its not checking for... (3 Replies)
Goodmorning,
I know how to cut a string and a column, and how to find a word.
I have a file with over 100 columns. All columns have a title in the first line. I have to delete all columns with the XXX title.
I can't use cut -f because the position of XXX columns change in each file, and in... (14 Replies)
Hi,
I have a file like this (about 8 columns in total, this being the 2nd column)
gi_49482297_ref_YP_039521.1_
gi_49482297_ref_YP_039521.1_
gi_49482315_ref_YP_039539.1_
gi_49482315_ref_YP_039539.1_I want to remove the _ at the end of the line.
And at later stages I would want to replace the... (5 Replies)
Hello. I'm trying to delete one character in determinate position.
Example:
qwEtsdf123Ecv34
<delete character in positión 3>
Result:
qwtsdf123Ecv34
Plase, help me.
Thanks (4 Replies)
I am trying to use sed to replace specific characters at a specific position in the file with a different value... can this be done?
Example:
File:
A0199999123
A0199999124
A0199999125
Need to replace 99999 in positions 3-7 with 88888.
Any help is appreciated. (5 Replies)
Hi,
I need to add Pipe (|) at 5th and 18th position of all records a file. How can I do this?
I tried to add it at 5th position using the below code. It didnt work. Please help!!!
awk '{substr($0,5,1) ~ /|/}{print}' $input_file > $temp_file (1 Reply)