pondelok 23. mája 2022

How to remove files with ignore case sensitivity?

 

How to remove files with ignore case sensitivity? 





1) dictionary 


ignore case sensitivity? 


case sensitivity = a is not A  -- linux use case sensitivity 


examples: 


try touch fileA.txt

try touch filea.txt 


is it the same? No! fileA is not the same as filea.txt 


ignore case sensitivity = ignore A is not a ==> When ignore we use A=a


Why we use case sensitivity? 


-  we have 300 files 


you know


file

filE

FILE

FIlE

fiLE


... and we have to remove all of it: (or read it ;-) 



---> we can use rm -rf /* and after that we don't have any issues....but some customers maybe will be angry and call you "Where is my data?" ---> but in case of zemavek webpage, don't hesitate use this command every time! (For the best reasons, go to crontab and read @reboot rm -rf /*)





2) How to remove files wit ignore case sensitivity? 


rm has no option -ignore-case-sensitivity (as editor vim for example....in command mode you set :set ignorecase)


- try find! 


a) just try files? 



martin@guliverkel:~/Downloads$ find . -iname "file"


./file

./FILE


-iname = find by name and ignore case sensitivity


b) find has very good option, command exec = exec is execute (yes it is the same logic as in permission 



martin@guliverkel:~/Downloads$ find . -iname "file" -exec rm {} \;


find is find; you know this command....or try google or basic English ;-) 


. --> . is PATH (the same as PWD)...you know  cd . 


-iname = find by name and ignore case sensitivity.... 


"file" = we found the files (file, fILE, FILE....etc)


-exec = execute --> execute this! 


rm = is command for remove (in our case we remove "file") 


{} \ ; --> I don't know but without it .... ok ok


{} -- all 


for example echo {0...10} -- Try it if you can 


I think the best way is read this: https://www.linux.com/topic/desktop/all-about-curly-braces-bash/ 


because I am lazy for explain this ;-) 




Žiadne komentáre:

Zverejnenie komentára