Of course, before we move the files, we should create the target directory: $ mkdir logs/security_logs_loop & grep -lir 'security alert' logs | while read log do mv "$log" logs/security_logs_loop doneĪs we can see in the tree output above, after the command’s execution, the three log files have been moved to the target directory. You can use a variation of this command to find any file or. It’ll read each filename from grep‘s result and move the file to the target directory. 1.Youll typically use the find command with the syntax find /path -type f -iname filename. In the next step, a while loop will take over the control.
0 Comments
Leave a Reply. |