You can protect yourself from the fact that you have no visual control of the line that you are going to execute if you have enabled in advance the shell options histverify with shopt -s histverify. ![]() That will execute the last command finished in your history. If your purpose is to build your commandline piece after piece, so you have done ls, after ls | grep google, and only after you checked your output you can execute it in a subshell $(.) with rm -i $(ls | grep google)Ī faster and more dangerous way, is to use !! ls | grep google The option -i (interactive) will prompt for the confirmation, a good habit when you delete files with the parameter expansion.Ī solution close to the philosophy of your attempt That will select each filename with "google" in the middle that will finish for. deb) with "google" inside you can build your request with the wildcard * *google*.deb and do a simple rm -i *google*.deb Since you want to select all the packages (that finish with. bands/Megadeth Drums:Dirk Verbeuren See that the -l option tells xargs to execute grep for every filename. bands/Kings X Drums:Jerry Gaskill grep Drums. bands/Rush Drums: Neil Peart grep Drums. ![]() bands/Dream Theater Drums:Mike Mangini grep Drums. It's better to use find, the tab expansion (start to write the name and press Tab), the file name expansion as *MyKey*. /bands -type f xargs -d n -l -t grep Drums grep Drums. This for many reasons mainly related to unexpected and not usual characters allowed in the file name.Įven when you should expect that the filenames belonging to Linux packages will "behave well", this problem can nonetheless appears if other files are present in the same directory but you didn't know or notice. My suggestion is to avoid to parse the output of ls, even more if in conjunction with the del command.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |