Remove all character after non ascii charater in all column

Multi tool use
Multi tool use

The name of the pictureThe name of the pictureThe name of the pictureClash 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
~
~






share|improve this question




















  • post a testable input file fragment
    – RomanPerekhrest
    Nov 29 '17 at 8:09














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
~
~






share|improve this question




















  • post a testable input file fragment
    – RomanPerekhrest
    Nov 29 '17 at 8:09












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
~
~






share|improve this question












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
~
~








share|improve this question











share|improve this question




share|improve this question










asked Nov 29 '17 at 6:32









Midhun

1




1











  • 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




post a testable input file fragment
– RomanPerekhrest
Nov 29 '17 at 8:09










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.






share|improve this answer




















  • 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











Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













 

draft saved


draft discarded


















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






























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.






share|improve this answer




















  • 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















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.






share|improve this answer




















  • 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













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.






share|improve this answer












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.







share|improve this answer












share|improve this answer



share|improve this answer










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

















  • 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


















 

draft saved


draft discarded















































 


draft saved


draft discarded














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













































































aXo6C2yrzi6t,3w,yZgKTj oRvxgd
1MSPomRUn zb9A6rj IDzoe lng

Popular posts from this blog

How to check contact read email or not when send email to Individual?

How many registers does an x86_64 CPU actually have?

Displaying single band from multi-band raster using QGIS