(g)awk conditional substitution issues when attempting to delete character
A portion of my input is as follows:
I would like the following desired output:
In essence, I would like to delete every W in field $9 while preserving the original, pre-substitution formatting, given the following regex condition:
However, I would want the formatting of the file to be preserved. I realize this has been dealt with in previous posts and I know how to use
and/or
(with gawk), but since my file is 61 fields long (NF==61; I've only presented a portion here), this is tremendously cumbersome and messy. In addition, I do not know every fieldwidth and so would like to avoid figuring this out to reformat the file.
I've had a similar issue in the past, and RudiC helped me via a very nifty trick taking advantage of NF being recomputed when there is an assignment to $0. Thus, I attempted the following:
This time however, it seems as those when doing the field substitution, the operation is aborted because of the non-escaped meta-character "[" that is in my data. This produces the following error in field 9 of a different line:
In light of this, I've also attempted:
Not only does this ruin the formatting of the file, but it is also matching lines I wouldn't expect it to such as:
Thank you so much in advance for helping me through this quagmire.
---------- Post updated at 11:00 AM ---------- Previous update was at 10:49 AM ----------
This is probably fairly obvious, but I should say that in my data examples from my post, the numbers on the far left are line numbers and not $1.
Hi ,
I have a problem , I need to devlope a script where in the user inputs file name , line number , and character position , and a substitution variable , the character at that character position should be substituted by the substitution value
for ex
say i have a file
abc.txt
which... (3 Replies)
Hi
I have to replace in around 60 files a word an replcae it by another
Suppose all the files have a word intelligent i want to replace it by idiot
I am planning to use sed for executing this job
sed 's/\intelligent/idiot/g'
I plan to have a file (test.txt) which contains... (1 Reply)
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)
Hi Gurus,
I am working with a korn shell script. I should replace in a very great file the character ";" with a space.
Example:
2750;~
2734;~
2778;~
2751;~
2751;~
2752;~
what the fastest method is? Sed? Awk?
Speed is dead main point, Seen the dimensions of the files
Thanks (6 Replies)
I'd like to remove (do a pattern or precise replacement - this I can handle in SED using Regex )
---AFTER THE 1ST Occurrence ( i.e. on the 2nd occurrence - from the 2nd to fourth occurance ) of a specific string : type 1
-- After the 1st occurrence of 1 string1 till the 1st occurrence of... (4 Replies)
Sample file:
This is line one,
this is another line,
this is the PRIMARY INDEX line
l ;
This is another line
The command should find the line with “PRIMARY INDEX” and remove the last character from the line preceding it (in this case , comma) and remove the first character from the line... (5 Replies)
Hi,
1/
i have file test.txt
1 Jul 28 08:35:29 2014-07-28 Root::UserA
1 Jul 28 08:36:44 2014-07-28 Root::UserB i want to delete the seconds of the file, and the Root:: and the output will be:
1 Jul 28 08:35 2014-07-28 UserA
1 Jul 28 08:36 2014-07-28 UserB 2/i have another file test2.txt:... (8 Replies)
i am trying to prepare a train and test dataset, for which i need to randomly split the data into corresponding folders (train,test)..
I began on a simple script, but seem to get som weird error messages, that i cannot make sense of?..
what am I doing wrong?
#!/bin/bash
RED='\033]
then... (13 Replies)
Hi Friends,
I have somefiles like
20180720_1812.tar.gz
20180720_1912.tar.gz
20180720_2012.tar.gz
20180720_2112.tar.gz
20180721_0012.tar.gz
20180721_0112.tar.gz
20180721_0212.tar.gz
20180721_0312.tar.gz
in a directory and so on..these files gets created every 3 hours where as... (28 Replies)
Hi
Please dont consider this as duplicated post..
I am using below pattern to find delete files to bringdown disc size.. however how i can make sure ist going to correct folder and searching for files... while print "echo rm " LastFile correctly print files names for deletion, but when i... (7 Replies)