Find ";" between Text


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Find ";" between Text
# 1  
Old 06-05-2015
Find ";" between Text

Hi,

I find in character ; text in between as shown in the example :
Code:
CECILIA P;ACENCIA P;ACENCIA

Print all Line.

Using regular expressions like [A-Z];[A-Z],it would be better to use sed ? that way ?


Thanks


Moderator's Comments:
Mod Comment
Please wrap all code, files, input & output/errors in CODE tags.
It makes them far easier to read and preserves multiple spaces for indenting or fixed width data.

Last edited by rbatte1; 06-05-2015 at 01:30 PM.. Reason: ICode tags, Code tags & moderator comment
# 2  
Old 06-05-2015
Welcome josefinaaraya,

I have a few questions:-
  • Is the above record part of a larger file?
  • Are there any other ; in the file, and can they all be removed?
  • Is this a one-off conversion or will it be a regular thing?
  • Is performance an issue?
  • What commands are you most familiar with?
  • What have you tried so far? It would be easier to see an attempt to make suggestions to.



Thanks, in advance,
Robin
# 3  
Old 06-05-2015
Hi,



The file has a size of 250,000 lines.
The file is based on a csv format divided by semicolons, but I just want to find where a semicolon in between text exist.
This script must do once.
Performance is not the problem, it's just solve.
I've done some work in AWK and gsub.
My attempts with examples:

*
Code:
sed -e ". s | *, || g" -e ". s | - * || g" R505_Baa

sed -n 's /^.* \ (\ [[A-Z] * \] \). * / \ 1 / p' R505_Baa




Where R505_Baa:


Code:

        104136761;                                                JUAN CARVAJAL CARVAJAL;10413676;N;;;;20070206;    1;
        103446759;                                                    JOHANA REYES REYES;10344675;N;;;;20100330;    1;
        103294150;                                      ACHURRA BURGOS JUAN MAURICIO * *;10329415;N;;;;20040707;    1;
        104969798;                                     FREDDY ALBINO SEPULVEDA SEPULVEDA;10496979;N;;;;20070511;    1;
        104843778;                                           CECILIA P;ACENCIA P;ACENCIA;10484377;N;;;;20020916;    1;
        103828589;                                                    VICTOR CERON CERON;10382858;N;;;;20030623;    1;


Last edited by rbatte1; 06-05-2015 at 01:51 PM.. Reason: Added CODE tags for the code
# 4  
Old 06-05-2015
So - you want to print - NOT modify! - lines that have a semicolon surrounded by uppercase alphabetic characters (no spaces, no digits, no punct ...).
You were on the right track. Try
Code:
grep '[A-Z];[A-Z]' file

or
Code:
awk '/[A-Z];[A-Z]/' file

or
Code:
sed -n '/[A-Z];[A-Z]/p' file

# 5  
Old 06-05-2015
That works , but prints more than desired :

EXAMPLE:

Code:
                  N;N; 0000 ; C


Then I want to restrict prints only if the semicolon is in between more than 3 characters Type [A-Z]


Thanks

Last edited by Scrutinizer; 06-05-2015 at 03:27 PM.. Reason: code tags
# 6  
Old 06-05-2015
Then you'll lose your other line.
# 7  
Old 06-05-2015
I do not understand what you're trying to say
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

find files in sub dir with tag & add "." at the beginning [tag -f "Note" . | xargs -0 {} mv {} .{}]

I am trying find files in sub dir with certain tags using tag command, and add the period to the beginning. I can't use chflags hidden {} cause it doesn't add period to the beginning of the string for web purpose. So far with my knowledge, I only know mdfind or tag can be used to search files with... (6 Replies)
Discussion started by: Nexeu
6 Replies

2. Shell Programming and Scripting

Bash script - Print an ascii file using specific font "Latin Modern Mono 12" "regular" "9"

Hello. System : opensuse leap 42.3 I have a bash script that build a text file. I would like the last command doing : print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt where : print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies

3. Shell Programming and Scripting

find . -path "*_nobackup*" -prune -iname "*.PDF" \( ! -name "*_nobackup.*" \)

These three finds worked as expected: $ find . -iname "*.PDF" $ find . -iname "*.PDF" \( ! -name "*_nobackup.*" \) $ find . -path "*_nobackup*" -prune -iname "*.PDF" They all returned the match: ./folder/file.pdf :b: This find returned no matches: $ find . -path "*_nobackup*" -prune... (3 Replies)
Discussion started by: wolfv
3 Replies

4. Shell Programming and Scripting

How to find a file which are not ends with ".zip" and which are ends with "*.log*" or "*.out*"?

I am new to bash/shell scripting. I want to find all the files in directory and subdirectories, which are not ends with “.zip” and which are contains in the file name “*.log*” or “*.out*”. I know below command to get the files which ends with “.log”; but I need which are not ends with this... (4 Replies)
Discussion started by: Mallikgm
4 Replies

5. Shell Programming and Scripting

Find lines with "A" then change "E" to "X" same line

I have a bunch of random character lines like ABCEDFG. I want to find all lines with "A" and then change any "E" to "X" in the same line. ALL lines with "A" will have an "X" somewhere in it. I have tried sed awk and vi editor. I get close, not quite there. I know someone has already solved this... (10 Replies)
Discussion started by: nightwatchrenba
10 Replies

6. Shell Programming and Scripting

Using sed to find text between a "string " and character ","

Hello everyone Sorry I have to add another sed question. I am searching a log file and need only the first 2 occurances of text which comes after (note the space) "string " and before a ",". I have tried sed -n 's/.*string \(*\),.*/\1/p' filewith some, but limited success. This gives out all... (10 Replies)
Discussion started by: haggismn
10 Replies

7. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

8. Shell Programming and Scripting

"find command" to find the files in the current directories but not in the "subdir"

Dear friends, please tell me how to find the files which are existing in the current directory, but it sholud not search in the sub directories.. it is like this, current directory contains file1, file2, file3, dir1, dir2 and dir1 conatins file4, file5 and dir2 contains file6,... (9 Replies)
Discussion started by: swamymns
9 Replies

9. Shell Programming and Scripting

grep to find content in between curly braces, "{" and "},"

problem String ~~~~~~~~~~~~~~~~~~ icecream= { smart peopleLink "good" LC "happy" , smartpeopleLink "dull" LC "sad" } aend = {smart vc4 eatr kalu} output needed ~~~~~~~~~~~~~~~~~~ smart peopleLink "good" LC "happy" , smartpeopleLink "dull" LC "sad" smart vc4... (4 Replies)
Discussion started by: keshav_rk
4 Replies

10. UNIX for Dummies Questions & Answers

Convert "text" to "packed-decimal"?

Is there a way with HP-UX Release 10.20 (but going to HP-UX 11) to convert a regular "text" file to a packed data format (such as is created by a Cobol program)? (2 Replies)
Discussion started by: HuskyJim
2 Replies
Login or Register to Ask a Question