special charter at bunch of .csv i want to run script with for loop but not removing in single command it is identifying but not removing
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
special charter at bunch of .csv i want to run script with for loop but not removing in single command it is identifying but not removing
Dear all,
I am using Centos and with below command i am finding special character in file but i need to go line by line and remove character and then save file and again need to run same command i have arround 100+ files it is very much difficult to do activity for each file one by one so i try to write script with same command but not working .
Are you sure it is finding the files correctly? Boolean logic dictates a specific precedence for logical AND and OR. So grouping is necessary to get the effect it looks like you are aiming for:
Then you'll have to define more clearly what you mean by special characters and which ones you want removed. iconv converts and if the characters are still there after the conversion, then they were successfully converted which appears to be something other than what you want.
Have you looked at tr instead? See especially the -c and -d options. I'm not sure how well it handles UTF-8 though.
kindly use some punctuation in your typing so that is would look like a piece of text not just a sequence of words also instead of not working please quote the exact error message
Code:
find ./ \( -name "*.csv" -o -name "*.html" -o -name "*.css" -o -name "*.js" \) -type f |
while read file
do
if iconv -f UTF-8 -t ISO-8859-15 "$file" >"$file.ocv"; then
printf "Converted '%s'\n" "$file"
mv "$file.ocv" "$file"
else
rm -f "$file.ocv"
printf "*** Couldn't convert '%s'\n" "$file"
fi
done
Please place your code snippets inside [CODE]...[/CODE] tags for better readability. You may type those yourself or click the "#" button in the edit controls.
"not working" is not a useful description of the problem. Please explain how it is not working and include any error messages.
If some files seem to produce bad results while others do not, it woul dbe helpful to pick a specific example and try to identify why it fails. If possible reduce the file to a single line or a few lines which cause the failure and post that example here, along with the exact filename and the command you are using.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.