Discussion:
search string in column ans delete line
MOKRANI Rachid rachid.mokrani@ifpen.fr [sed-users]
2016-03-22 16:19:36 UTC
Permalink
Hi,

Do you have a simple proposal with sed / awk.

if I find alphabetic characters (a-z A-Z) in column 7 I want to delete the line.


"111222333";"Company A";"NAME A ";"FIRSTNAME 1";"JOB 1";"Town 1";"52.45.0";"COMMENT 1";

"111222334";"Company A";"NAME A ";"FIRSTNAME 4";"JOB 1";"Town 1";"PH56.2458";"";

"118822333";"Company B";"NAME T ";"FIRSTNAME 1";"JOB 2";"Town 2";"aGrfDPHONE 65"; "COMMENT 1235";

"111275333";"Company C";"NAME M ";"FIRSTNAME 2";"JOB 7";"Town 1";"14582";"";

"55222334";"Company Y";"NAME G ";"FIRSTNAME 4";"JOB 52";"Town 1";"-45852";"";

"1258425";"Company Y";"NAME F ";"FIRSTNAME 8";"JOB 82";"Town 3";"+45 85 20";"";





Need to obtain the result below.


"111222333";"Company A";"NAME A ";"FIRSTNAME 1";"JOB 1";"Town 1";"52.45.0";"COMMENT 1";

"111275333";"Company C";"NAME M ";"FIRSTNAME 2";"JOB 7";"Town 1";"14582";"";

"55222334";"Company Y";"NAME G ";"FIRSTNAME 4";"JOB 52";"Town 1";"-45852";"";

"1258425";"Company Y";"NAME F ";"FIRSTNAME 8";"JOB 82";"Town 3";"+45 85 20";"";


Thanks,
Best regards.
__________________________
Avant d'imprimer, pensez à l'environnement ! Please consider the environment before printing !
Ce message et toutes ses piÚces jointes sont confidentiels et établis à l'intention exclusive de ses destinataires. Toute utilisation non conforme à sa destination, toute diffusion ou toute publication, totale ou partielle, est interdite, sauf autorisation expresse. IFP Energies nouvelles décline toute responsabilité au titre de ce message. This message and any attachments are confidential and intended solely for the addressees. Any unauthorised use or dissemination is prohibited. IFP Energies nouvelles should not be liable for this message.
__________________________


[Non-text portions of this message have been removed]
Tim Chase sed@thechases.com [sed-users]
2016-03-22 17:17:33 UTC
Permalink
Post by MOKRANI Rachid ***@ifpen.fr [sed-users]
Do you have a simple proposal with sed / awk.
if I find alphabetic characters (a-z A-Z) in column 7 I want to delete the line.
sounds like you want something like

awk -F\; '$2 !~ /[a-zA-Z]/' < in.txt > out.txt

Though you'll hit a snag if any of the quoted fields can contain a
delimiting ";" character.

-tkc
Tim Chase sed@thechases.com [sed-users]
2016-03-22 17:49:29 UTC
Permalink
Post by Tim Chase ***@thechases.com [sed-users]
Post by MOKRANI Rachid ***@ifpen.fr [sed-users]
Do you have a simple proposal with sed / awk.
if I find alphabetic characters (a-z A-Z) in column 7 I want to delete the line.
awk -F\; '$2 !~ /[a-zA-Z]/' < in.txt > out.txt
and of course I mean "$7" because you want to test the 7th column,
instead of the "$2" I used when testing it. :-P

-tkc
Thierry Blanc Thierry.Blanc@gmx.ch [sed-users]
2016-03-22 17:24:01 UTC
Permalink
sed -rn '/([^;]*;){6}[^;]*[A-Za-z][^;]*;[^;]*;/!p' yourfile
Post by MOKRANI Rachid ***@ifpen.fr [sed-users]
Hi,
Do you have a simple proposal with sed / awk.
if I find alphabetic characters (a-z A-Z) in column 7 I want to delete the line.
"111222333";"Company A";"NAME A ";"FIRSTNAME 1";"JOB 1";"Town 1";"52.45.0";"COMMENT 1";
"111222334";"Company A";"NAME A ";"FIRSTNAME 4";"JOB 1";"Town 1";"PH56.2458";"";
"118822333";"Company B";"NAME T ";"FIRSTNAME 1";"JOB 2";"Town 2";"aGrfDPHONE 65"; "COMMENT 1235";
"111275333";"Company C";"NAME M ";"FIRSTNAME 2";"JOB 7";"Town 1";"14582";"";
"55222334";"Company Y";"NAME G ";"FIRSTNAME 4";"JOB 52";"Town 1";"-45852";"";
"1258425";"Company Y";"NAME F ";"FIRSTNAME 8";"JOB 82";"Town 3";"+45 85 20";"";
Need to obtain the result below.
"111222333";"Company A";"NAME A ";"FIRSTNAME 1";"JOB 1";"Town 1";"52.45.0";"COMMENT 1";
"111275333";"Company C";"NAME M ";"FIRSTNAME 2";"JOB 7";"Town 1";"14582";"";
"55222334";"Company Y";"NAME G ";"FIRSTNAME 4";"JOB 52";"Town 1";"-45852";"";
"1258425";"Company Y";"NAME F ";"FIRSTNAME 8";"JOB 82";"Town 3";"+45 85 20";"";
Thanks,
Best regards.
__________________________
Avant d'imprimer, pensez à l'environnement ! Please consider the environment before printing !
Ce message et toutes ses piÚces jointes sont confidentiels et établis à l'intention exclusive de ses destinataires. Toute utilisation non conforme à sa destination, toute diffusion ou toute publication, totale ou partielle, est interdite, sauf autorisation expresse. IFP Energies nouvelles décline toute responsabilité au titre de ce message. This message and any attachments are confidential and intended solely for the addressees. Any unauthorised use or dissemination is prohibited. IFP Energies nouvelles should not be liable for this message.
__________________________
[Non-text portions of this message have been removed]
------------------------------------
------------------------------------
Rakesh Sharma sharma__r@hotmail.com [sed-users]
2016-03-22 20:24:32 UTC
Permalink
Requirement: if find alphabetic characters (a-z A-Z) in column 7, delete the line.
sed -e '
s/;/\n/7
s/;/\n/6

/\n.*[a-zA-Z].*\n/d

y/\n/;/
' yourcsvfile



________________________________

From: sed-***@yahoogroups.com <sed-***@yahoogroups.com> on behalf of MOKRANI Rachid ***@ifpen.fr [sed-users] <sed-***@yahoogroups.com>
Sent: Tuesday, March 22, 2016 9:19 AM
To: sed-***@yahoogroups.com
Subject: search string in column ans delete line



Hi,

Do you have a simple proposal with sed / awk.

if I find alphabetic characters (a-z A-Z) in column 7 I want to delete the line.

"111222333";"Company A";"NAME A ";"FIRSTNAME 1";"JOB 1";"Town 1";"52.45.0";"COMMENT 1";

"111222334";"Company A";"NAME A ";"FIRSTNAME 4";"JOB 1";"Town 1";"PH56.2458";"";

"118822333";"Company B";"NAME T ";"FIRSTNAME 1";"JOB 2";"Town 2";"aGrfDPHONE 65"; "COMMENT 1235";

"111275333";"Company C";"NAME M ";"FIRSTNAME 2";"JOB 7";"Town 1";"14582";"";

"55222334";"Company Y";"NAME G ";"FIRSTNAME 4";"JOB 52";"Town 1";"-45852";"";

"1258425";"Company Y";"NAME F ";"FIRSTNAME 8";"JOB 82";"Town 3";"+45 85 20";"";

Need to obtain the result below.

"111222333";"Company A";"NAME A ";"FIRSTNAME 1";"JOB 1";"Town 1";"52.45.0";"COMMENT 1";

"111275333";"Company C";"NAME M ";"FIRSTNAME 2";"JOB 7";"Town 1";"14582";"";

"55222334";"Company Y";"NAME G ";"FIRSTNAME 4";"JOB 52";"Town 1";"-45852";"";

"1258425";"Company Y";"NAME F ";"FIRSTNAME 8";"JOB 82";"Town 3";"+45 85 20";"";

Thanks,
Best regards.
__________________________
Avant d'imprimer, pensez à l'environnement ! Please consider the environment before printing !
Ce message et toutes ses pièces jointes sont confidentiels et établis à l'intention exclusive de ses destinataires. Toute utilisation non conforme à sa destination, toute diffusion ou toute publication, totale ou partielle, est interdite, sauf autorisation expresse. IFP Energies nouvelles décline toute responsabilité au titre de ce message. This message and any attachments are confidential and intended solely for the addressees. Any unauthorised use or dissemination is prohibited. IFP Energies nouvelles should not be liable for this message.
__________________________

[Non-text portions of this message have been removed]





[Non-text portions of this message have been removed]

Loading...