LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-07-2011, 09:20 PM   #1
anishkumarv
Member
 
Registered: Feb 2010
Location: chennai - India
Distribution: centos
Posts: 289

Rep: Reputation: 10
Need to change the Index.html alone!!!


Hi all,


I want to remove the index.html file alone in the every directory via

bash script,

for example i have 5 directories in the path /var/www/vhost

anish
kumar
linux
question
friend

each directories have index.html file now i want to replace the index.html file alone from the other directory /var/tmp/vhosbak

anish
kumar
linux
question
friend

How we can do this using script?
 
Old 07-07-2011, 09:35 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
find -iname index.html -exec rm {} \;

Just an example, don't actually RUN that.
 
Old 07-07-2011, 10:04 PM   #3
anishkumarv
Member
 
Registered: Feb 2010
Location: chennai - India
Distribution: centos
Posts: 289

Original Poster
Rep: Reputation: 10
Hi Tinkster,

Thanks for the reply using find command we can find and replace?
 
Old 07-07-2011, 10:36 PM   #4
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Perhaps something like this?
Code:
cd /var/www/vhost

for d in anish kumar linux question friend; do
  cp /var/tmp/vhosbak/index.html $d
  ls -l $d/index.html
done
 
Old 07-07-2011, 11:38 PM   #5
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
Quote:
Originally Posted by anishkumarv View Post
Hi Tinkster,

Thanks for the reply using find command we can find and replace?
Yup.
Code:
cd /var/www/vhost
find * -name index.html -exec cp ../tmp/vhosbak/{} {} \;
Should work.



Cheers,
Tink
 
1 members found this post helpful.
Old 07-09-2011, 05:23 AM   #6
anishkumarv
Member
 
Registered: Feb 2010
Location: chennai - India
Distribution: centos
Posts: 289

Original Poster
Rep: Reputation: 10
Hi Tinkster,

It works great thanks alot :-)
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
apache index.html doesn't show up but index.php do zoffmann Linux - Server 5 01-28-2008 03:53 PM
Where to put index.php (or index.html) on Slackware 11.0 moonguide Slackware 3 05-08-2007 06:35 PM
How to change the path of my index.html website? cucolin@ Linux - Software 2 08-07-2006 03:30 PM
Apache index.html edit makes no change dwbrown Linux - Software 2 09-29-2004 11:36 AM
How to change the default index.html in Apache bngrhl Linux - Newbie 2 06-08-2004 01:47 PM


All times are GMT -5. The time now is 08:48 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration