Remove all character after non ascii charater in all column
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
I have a bash script which will remove all the Non Ascii character from the file. But i wanted to remove the string after the non Ascii character in all the columns. Below is the script,
> #!/bin/bash
SCRIPT_PATH=/trmout/TRMOUTPUT_PROD
BKP_PATH=/appinfprd/bi/infogix/Temp_Files/SUPPLY_CHAIN
File_Name=WB
########################################################################
##Deleting the precessed files ####
########################################################################
cd $BKP_PATH
rm *.*
#########################################################################
### removing the non ascii char from all Supply chain files #######
#########################################################################
for i in $SCRIPT_PATH/$File_Name*.txt
do
cp $i $BKP_PATH
##########################################################################
##Replacing the NON ASCII Char from Supply Chain files and saving it.####
##########################################################################
cat $i >> $i.bkp
sed -i 's/[d128-d255]//g' $i.bkp
mv $i.bkp $i
done
#############################################################################################
##Creating a sample file which will be having the file name which has NON ASCII Char in it.##
#############################################################################################
cd $SCRIPT_PATH
grep -vlP '^[-x7f]*$' WB*.txt >Supply_chain_Non_Ascii_List_File.txt
~
~
bash shell-script shell
add a comment |Â
up vote
0
down vote
favorite
I have a bash script which will remove all the Non Ascii character from the file. But i wanted to remove the string after the non Ascii character in all the columns. Below is the script,
> #!/bin/bash
SCRIPT_PATH=/trmout/TRMOUTPUT_PROD
BKP_PATH=/appinfprd/bi/infogix/Temp_Files/SUPPLY_CHAIN
File_Name=WB
########################################################################
##Deleting the precessed files ####
########################################################################
cd $BKP_PATH
rm *.*
#########################################################################
### removing the non ascii char from all Supply chain files #######
#########################################################################
for i in $SCRIPT_PATH/$File_Name*.txt
do
cp $i $BKP_PATH
##########################################################################
##Replacing the NON ASCII Char from Supply Chain files and saving it.####
##########################################################################
cat $i >> $i.bkp
sed -i 's/[d128-d255]//g' $i.bkp
mv $i.bkp $i
done
#############################################################################################
##Creating a sample file which will be having the file name which has NON ASCII Char in it.##
#############################################################################################
cd $SCRIPT_PATH
grep -vlP '^[-x7f]*$' WB*.txt >Supply_chain_Non_Ascii_List_File.txt
~
~
bash shell-script shell
post a testable input file fragment
â RomanPerekhrest
Nov 29 '17 at 8:09
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have a bash script which will remove all the Non Ascii character from the file. But i wanted to remove the string after the non Ascii character in all the columns. Below is the script,
> #!/bin/bash
SCRIPT_PATH=/trmout/TRMOUTPUT_PROD
BKP_PATH=/appinfprd/bi/infogix/Temp_Files/SUPPLY_CHAIN
File_Name=WB
########################################################################
##Deleting the precessed files ####
########################################################################
cd $BKP_PATH
rm *.*
#########################################################################
### removing the non ascii char from all Supply chain files #######
#########################################################################
for i in $SCRIPT_PATH/$File_Name*.txt
do
cp $i $BKP_PATH
##########################################################################
##Replacing the NON ASCII Char from Supply Chain files and saving it.####
##########################################################################
cat $i >> $i.bkp
sed -i 's/[d128-d255]//g' $i.bkp
mv $i.bkp $i
done
#############################################################################################
##Creating a sample file which will be having the file name which has NON ASCII Char in it.##
#############################################################################################
cd $SCRIPT_PATH
grep -vlP '^[-x7f]*$' WB*.txt >Supply_chain_Non_Ascii_List_File.txt
~
~
bash shell-script shell
I have a bash script which will remove all the Non Ascii character from the file. But i wanted to remove the string after the non Ascii character in all the columns. Below is the script,
> #!/bin/bash
SCRIPT_PATH=/trmout/TRMOUTPUT_PROD
BKP_PATH=/appinfprd/bi/infogix/Temp_Files/SUPPLY_CHAIN
File_Name=WB
########################################################################
##Deleting the precessed files ####
########################################################################
cd $BKP_PATH
rm *.*
#########################################################################
### removing the non ascii char from all Supply chain files #######
#########################################################################
for i in $SCRIPT_PATH/$File_Name*.txt
do
cp $i $BKP_PATH
##########################################################################
##Replacing the NON ASCII Char from Supply Chain files and saving it.####
##########################################################################
cat $i >> $i.bkp
sed -i 's/[d128-d255]//g' $i.bkp
mv $i.bkp $i
done
#############################################################################################
##Creating a sample file which will be having the file name which has NON ASCII Char in it.##
#############################################################################################
cd $SCRIPT_PATH
grep -vlP '^[-x7f]*$' WB*.txt >Supply_chain_Non_Ascii_List_File.txt
~
~
bash shell-script shell
asked Nov 29 '17 at 6:32
Midhun
1
1
post a testable input file fragment
â RomanPerekhrest
Nov 29 '17 at 8:09
add a comment |Â
post a testable input file fragment
â RomanPerekhrest
Nov 29 '17 at 8:09
post a testable input file fragment
â RomanPerekhrest
Nov 29 '17 at 8:09
post a testable input file fragment
â RomanPerekhrest
Nov 29 '17 at 8:09
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
0
down vote
Do you mean you want to delete anything on the line after the first non-ascii character ? If not, please provides some examples.
If yes, your sed should be :
sed -i 's/[d128-d255].*$//' $i.bkp
This will replace the first non-ascii character AND the rest of the line with nothing.
sed -i 's/[d128-d255][^|]*|/|/' WB* < $i.bkp This will replace the first non-ascii character till the first Column seperated by |.
â Midhun
Dec 5 '17 at 3:58
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
Do you mean you want to delete anything on the line after the first non-ascii character ? If not, please provides some examples.
If yes, your sed should be :
sed -i 's/[d128-d255].*$//' $i.bkp
This will replace the first non-ascii character AND the rest of the line with nothing.
sed -i 's/[d128-d255][^|]*|/|/' WB* < $i.bkp This will replace the first non-ascii character till the first Column seperated by |.
â Midhun
Dec 5 '17 at 3:58
add a comment |Â
up vote
0
down vote
Do you mean you want to delete anything on the line after the first non-ascii character ? If not, please provides some examples.
If yes, your sed should be :
sed -i 's/[d128-d255].*$//' $i.bkp
This will replace the first non-ascii character AND the rest of the line with nothing.
sed -i 's/[d128-d255][^|]*|/|/' WB* < $i.bkp This will replace the first non-ascii character till the first Column seperated by |.
â Midhun
Dec 5 '17 at 3:58
add a comment |Â
up vote
0
down vote
up vote
0
down vote
Do you mean you want to delete anything on the line after the first non-ascii character ? If not, please provides some examples.
If yes, your sed should be :
sed -i 's/[d128-d255].*$//' $i.bkp
This will replace the first non-ascii character AND the rest of the line with nothing.
Do you mean you want to delete anything on the line after the first non-ascii character ? If not, please provides some examples.
If yes, your sed should be :
sed -i 's/[d128-d255].*$//' $i.bkp
This will replace the first non-ascii character AND the rest of the line with nothing.
answered Dec 1 '17 at 14:59
Hexdump
763
763
sed -i 's/[d128-d255][^|]*|/|/' WB* < $i.bkp This will replace the first non-ascii character till the first Column seperated by |.
â Midhun
Dec 5 '17 at 3:58
add a comment |Â
sed -i 's/[d128-d255][^|]*|/|/' WB* < $i.bkp This will replace the first non-ascii character till the first Column seperated by |.
â Midhun
Dec 5 '17 at 3:58
sed -i 's/[d128-d255][^|]*|/|/' WB* < $i.bkp This will replace the first non-ascii character till the first Column seperated by |.
â Midhun
Dec 5 '17 at 3:58
sed -i 's/[d128-d255][^|]*|/|/' WB* < $i.bkp This will replace the first non-ascii character till the first Column seperated by |.
â Midhun
Dec 5 '17 at 3:58
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f407657%2fremove-all-character-after-non-ascii-charater-in-all-column%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
post a testable input file fragment
â RomanPerekhrest
Nov 29 '17 at 8:09