LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
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 08-11-2013, 07:23 PM   #1
vaibhavtewari
LQ Newbie
 
Registered: Aug 2013
Posts: 3

Rep: Reputation: Disabled
Deleting files on multiple nodes on a cluster


I was wondering how to do this

I have files residing on folders

/atlas/node/*/user/vaibhav

where * is node1, node2, node2, .....node2000

I want to delete files residing on all these nodes, but if I try to do
rm /atlas/node/*/user/vaibhav/*

it doesn't work, saying "rm: No match."

it does work when I do
rm /atlas/node/node1234/vaibhav/*

so I was wondering how to delete files at once on all the nodes.

Thanks in advance
 
Old 08-11-2013, 08:47 PM   #2
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,356

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
You should b able to use find cmd with a wildcard spec for the dir eg http://www.unix.com/shell-programmin...directory.html.
NB: test this in a test dir first, or (better) use 'echo' instead of 'rm' to check before you do it for real.
 
Old 08-11-2013, 10:04 PM   #3
TRUNoise
Member
 
Registered: Apr 2013
Location: /home/
Distribution: Ubuntu 14.04
Posts: 50

Rep: Reputation: 7
A quick shell script could take care of this easily.

Code:
#!/bin/bash
nodes=$(ls /atlas/node/)
#nodes=( node1 node2 node3 ) #Incase you want to delete from specific folders

for i in "${nodes[@]}"
do
    Deleting from $i
    rm /atlas/node/$i/user/vaibhav/* -r
done
The script will remove everything in /user/vaibhav/ from all folders inside of /atlas/node/. I'm sure you can edit the script accordingly to fit your needs.

Last edited by TRUNoise; 08-11-2013 at 10:08 PM.
 
1 members found this post helpful.
Old 08-12-2013, 06:12 AM   #4
vaibhavtewari
LQ Newbie
 
Registered: Aug 2013
Posts: 3

Original Poster
Rep: Reputation: Disabled
Thank You for replying. Unfortunately wild cards didnt work for me, I tried something like

for n in {1..2000}; do cd '/atlas/node/n'$n'/user/vaibhav'; rm *; ls | wc -l; done

which worked. I figured this out on my own, but thank you for the second post which recommends the same thing.
 
Old 08-12-2013, 11:23 AM   #5
TRUNoise
Member
 
Registered: Apr 2013
Location: /home/
Distribution: Ubuntu 14.04
Posts: 50

Rep: Reputation: 7
Quote:
Originally Posted by vaibhavtewari View Post
Thank You for replying. Unfortunately wild cards didnt work for me, I tried something like

for n in {1..2000}; do cd '/atlas/node/n'$n'/user/vaibhav'; rm *; ls | wc -l; done

which worked. I figured this out on my own, but thank you for the second post which recommends the same thing.
If the post has no further problems and is done, please mark it [SOLVED] at the top of the thread. Thanks!
 
Old 08-12-2013, 01:03 PM   #6
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
One note - if, for some reason your delete loop is interrupted, you will get a lot of errors trying it again as some of the files will be missing. To avoid any abort, try "rm -f", so that the rm command will ignore missing files.
 
Old 08-12-2013, 02:08 PM   #7
vaibhavtewari
LQ Newbie
 
Registered: Aug 2013
Posts: 3

Original Poster
Rep: Reputation: Disabled
Thanks. How to mark this solved ?
 
Old 08-13-2013, 10:41 PM   #8
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,356

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
Try the 'Thread Tools' link at the top
 
Old 08-13-2013, 10:43 PM   #9
TRUNoise
Member
 
Registered: Apr 2013
Location: /home/
Distribution: Ubuntu 14.04
Posts: 50

Rep: Reputation: 7
Quote:
Originally Posted by vaibhavtewari View Post
Thanks. How to mark this solved ?
Click this link. http://www.linuxquestions.org/questi...d&t=4175473029
 
  


Reply



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
[SOLVED] deleting columns over multiple files atjurhs Linux - Newbie 34 10-01-2012 08:54 PM
Hwaddr of all nodes on a cluster usagi32 Linux - Server 4 09-10-2009 11:21 PM
deleting multiple files with # in name crazydrve Linux - Software 5 03-01-2006 02:41 AM
Cluster....which distro is best for the Nodes? KaptinKABOOM Linux - Software 7 06-14-2004 08:34 PM
How do i create an a/c at all nodes in the cluster dogma Linux - Networking 4 05-19-2003 10:21 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:40 PM.

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
Open Source Consulting | Domain Registration