advanced-bash-techniques
advanced bash techniques
find and change all files
sudo find . -type f -print0 | xargs -0 ls -hal
sudo find . -type f -print0 | xargs -0 sudo chown www-data:www-data
sudo find . -type f -print0 | xargs -0 sudo chmod 0644find and change all directories:
sudo find . -type d -print0 | xargs -0 sudo chmod 0775
Remove a particular line from all files in a directory
for file in /tmp/test/*
do
cp -p $file $file.tmp
egrep -v "RegexToRemove" $file.tmp > $file
rm -rf $file.tmp
doneapache logs count unique ip addresses
Bash Perl search and replace multiple files one liner
explanation:
- -e
means execute the following line of code.
- -i
means edit in-place
- -w
write warnings
- -p
loop
Remarkbox
Comments