Sponsored Content
Top Forums Shell Programming and Scripting Find all .htaccess files and make a backup copy in respective directories Post 302526172 by boxx on Monday 30th of May 2011 04:05:28 PM
Old 05-30-2011
Thanks for the explanation RDC,

I have the following two little bash scripts now, both working as hoped. =)

Code:
#! /bin/bash
#create_bak.sh
# find all .htaccess files and create a copy of them in their current dir as .htaccess_bak
# run this to backup .htaccess files prior to making proposed mass update.
find . -iname ".htaccess" -exec cp -v {} {}_bak \;

and

Code:
#! /bin/bash
#restore_bak.sh
# Find all .htaccess_bak files to restore, and change thier name to .htaccess to overwrite existing file. (vebose)
# Use this if the modifcations do not work as intended.
find . -type f -name ".htaccess_bak" |while read file
do
  mv -v "$file" "${file%_bak}"
done


Last edited by boxx; 05-30-2011 at 05:12 PM..
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

copy multiple files in different directories

I have a report file that is generated every day by a scheduled process. Each day the file is written to a directory named .../blah_blah/Y07/MM-DD-YY/reportmmddyy.tab I want to copy all of this reports to a separate directory without having to do it one by one. However, if I try cp... (3 Replies)
Discussion started by: ken2834
3 Replies

2. Shell Programming and Scripting

Make python script ignore .htaccess

I just wrote a tiny script with the help of ghostdog74 to search all my files for special content phrases. After a few modifications I now made it work, but one problem is left. The files are located in public_html folder, so there might also be .htaccess files. So I ignored scanning of that... (4 Replies)
Discussion started by: medic
4 Replies

3. UNIX for Dummies Questions & Answers

how can i copy those files into other directories have the same name

how can i copy those files into other directories have the same name but different in the end i have files in directory called test: 10_10_asdadfsdfad.txt 10_10_11_asdawqefwkjasd.txt 10_10_11_12_asdafjjhoqwd.txt i want to put them in exist directory thart i have on my system i have... (1 Reply)
Discussion started by: t17
1 Replies

4. Shell Programming and Scripting

Replace several numbers with respective tag and make a single file

Dear All, I have a final output files as 736645|0| 13879|1| 495563|10| 127933|14| 4975|16| 49038|6| 53560|7| 135115|8| 178857|9| Now I want to replace second column with respective tag as per the value (4 Replies)
Discussion started by: jojo123
4 Replies

5. Shell Programming and Scripting

Copy respective path next to last column with awk

Hi to all, I have the short print out sample of the DOS command "dir S/" as showed below. Directory of C:\Program Files\Winamp\Skins\Bento\window 02/12/2010 11:35 p.m. <DIR> . 02/12/2010 11:35 p.m. <DIR> .. 11/12/2009 10:31 a.m. 13,556... (3 Replies)
Discussion started by: cgkmal
3 Replies

6. Shell Programming and Scripting

Copy directories in make file

LD:=C:/WindRiver/diab/5.9.3.0/WIN32/bin/dld.exe CFILES:=$(wildcard *.c) OBJFILES:=$(subst .c,.o, $(CFILES)) OBJ_PATH:=$(PRJ_PATH)/out/ ADDOBJFILES := $(addprefix $(OBJ_PATH),$(OBJFILES)) FILES:=C:/EB/tresos/workspace/Test_Spi/output/src copyfiles: cp ... (3 Replies)
Discussion started by: ushacy
3 Replies

7. AIX

How to backup a directory (sub-directories/files) files from one server on to other ?

Hello, Server A: /directory1/ Server B: /Backups/ i wanted to backup contents of /directory1 from "server A" on to "Server B" every 1 hour. If there is any change in (only new/differences) contents on serverA (directory1/) supposed to be backeup on next run. I did used rsync command to... (5 Replies)
Discussion started by: System Admin 77
5 Replies

8. Shell Programming and Scripting

Copy files in respective directories

Hi Guys, I need to copy the files to respective directories based on name of the file. My script is something like below con=$1 for file in `cat $con` do file_tmp=$(ls -t1 $path| grep -i $file | head -n 1) echo $file_tmp if then cp $path$file_tmp $DIR/ap if then... (16 Replies)
Discussion started by: Master_Mind
16 Replies

9. Shell Programming and Scripting

Find and Copy Directories ONLY

I am trying to copy only the date specific folders/directories using the following command. However, the following copy command is also copying files from the root folder (OriginalFolder). find /OriginalFolder/ -type -d \{ -mtime 1 -o -mtime 2 \ } -exec cp -R {} /CopyTo/'hostname'__CopyTo/ \;... (2 Replies)
Discussion started by: apacheLinux
2 Replies
RDIFF-BACKUP-FS(1)					      General Commands Manual						RDIFF-BACKUP-FS(1)

NAME
rdiff-backup-fs - Filesystem for accessing rdiff-backup archives. SYNOPSIS
rdiff-backup-fs <mount_point> <repository> [repositories ...] [-option ...] DESCRIPTION
rdiff-backup-fs is a filesystem in userspace that reads rdiff-backup archives and provides convenient access. OPTIONS
--debug <0-4> Run rdiff-backup-fs in foreground with given verbosity of debug messages. -f, --full Store information about all revisions in memory. CAUTION: this may take a lot of memory if your archive contains many revisions. -l, --last Displays files from the most recent increment as directories, each holding every version of the file. CAUTION: this stores informa- tion about all revisions in memory and therefore may take a lot of memory if archive contains many revisions. -c <n>, --caching <n> How many files retrieved from the rdiff-backup archive may be cached by filesystem. By default rdiff-backup-fs will cache up to 10 files. If this switch is set to 0, no caching will be done. -r <n>, --revisions <n> How many revisions should be stored in memory for on demand revision retrieval. By default rdiff-backup-fs will store up to 10 revi- sions in memory. -d, --directory <path> Set directory for directory with temporary files. By default rdiff-backup-fs uses /tmp. -v, --version Print version of rdiff-backup-fs and exit. SEE ALSO
rdiff-backup(1) COPYRIGHT
rdiff-backup-fs is Copyright (c) 2007-2011 Filip Gruszczyski. rdiff-backup-fs is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MER- CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. AUTHORS
Filip Gruszczyski <gruszczy@gmail.com> RDIFF-BACKUP-FS(1)
All times are GMT -4. The time now is 12:48 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy