Hi,
I am in a situation wherein am getting file file certailn values
suppose
1u56979hhghhklklkkkjkjkjk 0 0 0
The file will have values like above only.
I need to add another field of NULL value(of length 9) at the end of first column i.e.
It should like this after editing:
1u56979hhghhklklkkkjkjkjk<NULL> 0 0 0
It sounds like you're trying to NUL terminate the first (whitespace delimited) field (word) of each line in a text file.
That's a very odd request (because the ASCII NUL character is normally used to terminate strings ... but normally NOT embedded in text files ... so many tools that might be trying to read the file line by line would not handle the NUL character gracefully.
It's also possible that your shell or your copy of sed or whatever cannot handle this cleanly. So you might need to use GNU versions of these tools, or a copy of Perl or Python (or compile up a little utility in C, of course).
The most obvious attempt in plain bash would be:
This is written as a filter so you pipe you file through it. To verify that it's doing what you want you can pipe the output further through a command like cat -A or od -x to be sure it shows the NUL characters where you want them.
That might have some odd artifacts (due to the way that each line is parsed by the set -- command). This following one-liner works in two stages, using sed the first space on each line to a character "177" (octal) --- hex 0x7F, a.k.a. the "DEL" character; and then using the tr command to change that into an ASCII NUL:
This assumes that the original file has no ASCII DEL character that you care about preserving ... and the example shows a cat -A just for your convenience. You'd replace that with an appropriate redirection to save your output.
He JimD
Thanks for your effort ! But I think we are not on same path....!
Let me explain my requirement more simply now,...
In my file I am getting rows as like this :
(Note : kindly copy/paste above rows in notepad to get real view)
Now I need to add an extra field og length-9 after first column with NULL value.
So after editing a row should look like this:
1US500100010000010001920077000131973511115107128101771004460001204600004 0 0 0 0
i.e. <1stcolumn value><9 spaces><2nd col value>....and so on..
Let me also tell file has many rows of similar format and size of file is 24mb.
Similarly in yet another requirement i need to add another field:
Field description:
Between 12 and 13 character in a row.i.e in first column
Value:NULL
Length:5
i.e 5 spaces after 12 th character in the first column.
Dear Guru's
I'm using Putty and want to edit a file. I know we generally use vi editor to do it. As I'm not good in using vi editor, I want to convert the vi into something like text pad. Is there any option in Putty to do the same ? Thanks for your response.
Srini (6 Replies)
Hi All,
I've to edit the below file in the
Current File:
XXX
Rows found with null for one or more non-nullable columns in the source table
SELECT
COUNT(*)
FROM
(
SELECT
1 as one
FROM
datum
WHERE:wall:
datum.ID IS NULL
)
a (1 Reply)
I have a file which has 10 million records in it. When am trying to edit the file with vi, the following error occurs:
~
~
~
~
~
~
~
~
"file1" Value too large for defined data type
Is there any way that I can edit this file without using vi? Any help would be really appreciated.... (8 Replies)
I have a text file that has data like:
Data "12345#22"
Fred
ID 12345
Age 45
Wilma
Dino
Data "123#22"
Tarzan
ID 123
Age 33
Jane
I need to figure out a way of adding 1,000,000 to the specific lines (always same format) in the file, so it becomes:
Data "1012345#22"
Fred
ID... (16 Replies)
Hi,
I am having a file which is fix length and comma seperated. And I want to replace values for one column.
I am reading file line by line in variable $LINE and then replacing the string.
Problem is after changing value and writing new file temp5.txt, formating of original file is getting... (8 Replies)
Hi all,
I have a file with following contents
# rad124
# radkus
# raddebug
# radtrace
I could like to remove the # and space present before the key word "rad".
Any ways to do this using "subsitution method(:%s/old/new/g)" will be hepful. (1 Reply)
I have created a file with vi -x (file name) this is encrypted file when i again open this file it ask me to enter a password before editing it.Can i remove this password but i don't want to delete a file how to do this.
Thanks (0 Replies)
hi! I am a newbee. I would really appreciate if you can answer the following question:
I have a huge data file, 214MB with several coloumns. I need to delete the very last line of the file. Everything I know takes a lot of time to do it ( because I have to open the file in an editor or run a... (3 Replies)