---------- Post updated at 07:35 AM ---------- Previous update was at 07:32 AM ----------
Quote:
Originally Posted by Don Cragun
Your request is extremely vague. What do you mean by?:
Do you want to delete the 2nd, 3rd, and 4th lines in the file?
Do you want to delete the 2nd, 3rd, and 4th fields in each line in the file?
What is in the lines other than unaccented uppercase letters and unaccented lowercase letters? If the fields are separated from each other by one or more space or tab characters do you also want the space and tab characters following the fields that are being removed to be removed or do you want to leave the separators unchanged?
Do you want to only print lines that have been changed, or do you want to every line after the changes have been completed. (Your current code appears to want to print unchanged lines once and changed lines twice.)
According to the standard, the use of 2g in
produces undefined results.
You can specify a count or the g flag, but not both.
Since you don't show us any of your input, you don't give us the output from the commands you listed, and you don't show us the output you want to get from a representative input file, any suggestions you get here will be wild conjecture as to whether or not you will get anything resembling what you want.
With the sed commands you are showing, I assume that you are trying to remove fields rather than lines, that you want to leave any field separators unchanged, and that you want to every line in the file once. In that case, something like:
will delete two or more letters in the 2nd, 3rd, 4th, and 14th nonadjacent occurrences of adjacent letters from every line. If a line has fewer occurrences of this condition, it will still make changes to any of the times the request is matched. If the input file (9) contains:
the output will be:
I want to delete the 2nd, 3rd, and 4th fields in each line in the file, can we use one line sed to handle this?
Hi,
I have two files test1,test2. If the number in test1 file exist in test2 then i want to remove that from test2 file.
Ex:
File- test1
12
13
14
15
==============
File- test2
1A~12
2B~13
3C~33
4D~22
I want to remove row which contains 12,13 from test2. I am using this sed... (2 Replies)
Hi All,
I am very new to UNIX...
I was trying to delete ^ from a file and save it with different name...
The version is AIX 5.3
The input file is in this directory /a/b
The Input file name is o9876.out
I want the output file in same path with different name like ABC.txt... (5 Replies)
Hi,
I have a text file with content as follows:
bla foo3200492
comment on this: 3900302
here comes the teddy 12
all I need is:
3200492
3900302
12
So I need the correct "sed" command to delete everything until the first number.
I am not a regex expert, because I have to... (3 Replies)
I have tried doing this to delete some lines: sed '1,10d' file
Now I want to specify a variable as a line number for example:
lastline=wc -l file
linestart=$lastline - 20
sed '$linestart,$lastlined' file
but this will give error: sed: -e expression #1, char 3: extra characters after... (4 Replies)
I am not able to analyze the below code..
What I expected is that DELETED will be replaced with the first field in every line.But after giving a try, the output was different.
Can anyone pleas analyze and explain the code in detail?
Many thanks...
$ sed 's/* /DELETED /g' g1.txt > g4.txt... (2 Replies)
I am trying to use sed to delete the ^M at the end of the line and when i pass a file './asciiFix.sh wintest.txt' I get an error saying sed: can't read : no such file or dir. Can someone give me a pointer as to what I am doing wrong?
#!/bin/sh
if file "$@" | grep "with CRLF"; then
echo... (5 Replies)
input
"A","B","C,D","E","F"
"S","T","U,V","W","X"
"AA","BB","CC,DD","EEEE","FFF"
required output:
"A","B","C,D","C,D","F"
"S", T","U,V","U,V","X"
"AA","BB","CC,DD","CC,DD","FFF"
tried using awk but double quotes not preserving for every field. any help to solve this is much... (5 Replies)