Removing some lines from a big text file ?
Closed
pierre1
-
7 Mar 2010 à 05:56
Richard.Williams Posts 25 Registration date Saturday 7 November 2009 Status Member Last seen 18 July 2012 - 11 Mar 2010 à 09:28
Richard.Williams Posts 25 Registration date Saturday 7 November 2009 Status Member Last seen 18 July 2012 - 11 Mar 2010 à 09:28
Related:
- Removing some lines from a big text file ?
- Dvi file - Guide
- Windows 10 iso file download 64-bit - Download - Windows
- Pokemon emerald rom file - Download - Role playing
- How to open .ps file - Guide
- Safari cannot open the page because it is a local file - Guide
1 response
Richard.Williams
Posts
25
Registration date
Saturday 7 November 2009
Status
Member
Last seen
18 July 2012
14
11 Mar 2010 à 09:28
11 Mar 2010 à 09:28
This script will remove all lines that contain any international char. Basically, it ensures that each line has characters only from a-z, A-Z, 0-9, space, tab, comma, colon, semicolon.
Save the script in file C:/Scripts/IntlNames.txt, start biterscripting, enter this command.
This will remove all lines with intl chars from file C:/testfile.txt. 50000 lines is pretty small file.
# Script IntlNames.txt
str file, content, line, approvedlist
# Approved list of characters. Enclose this list between ^(#...)^.
set $approvedlist = "^(#a-zA>Z0>9 \,\:\;)^"
# Get file contents into a variable.
cat $file > $content
# Go thru lines one by one.
lex "1" $content > $line
while ($line <> "")
do
# Does this line contain any character outside our "approved" list of characters ?
if ( { chen -r $approvedlist $line } == 0)
# No unapproved chars - this is a "good" line.
echo $line
endif
# Get the next line
lex "1" $content > $line
done
Save the script in file C:/Scripts/IntlNames.txt, start biterscripting, enter this command.
script "C:/Scripts/IntlNames.txt" file("C:/testfile.txt") > "C:/testfile.txt"
This will remove all lines with intl chars from file C:/testfile.txt. 50000 lines is pretty small file.