HI
i have below command and i want to run it on each logs of each and every Dir.
/home/Laco/Al
I have sub dir in this folder
/home/Laco/Al/04092012/LP/X/.logs
/home/Laco/Al/04092012/LP/Y/.logs
/home/Laco/Al/04092012/LP/Z/.logs
/home/Laco/Al/04092012/LP/P/.logs
I want to run command
tr -c '[:print:][:cntrl:]' '[-*]' | sed 's/---/-/g'
and save output at same file.
Basically it replace ASCI Value
Thanks
for file in `find . -type f -name \*.logs`;do
cat $file | tr -c '[:print:][:cntrl:]' '[-*]' | sed 's/---/-/g' > $file"_tmp"
mv $file"_tmp" $file
done
1 Like
methyl
3
Correction and rearrangement of 47shailesh post.
No attempt to test the tr
command syntax because it is some weird Linux (i.e. non-unix) extension.
find . -xdev -type f -name \*.logs | while read filename
do
cat "${filename}" | tr -c '[:print:][:cntrl:]' '[-*]' | sed 's/---/-/g' > "${filename}_tmp"
mv "$filename_tmp" "${filename}"
done
1 Like
Not solved ....can you please help me with perfect script.....
error mv: cannot access
Thanks
Combining input from the other thread, try this. First test it out on a test directory structure..
for file in */LP/*/*.logs
do
LANG=C sed 's/[^[:print:][:cntrl:]]\{1,\}/-/g' "$file" > "$file.new" && mv -- "$file.new" "$file"
done
1 Like
Thanks a lot it's working....
Thanks a lot all of you