UNIX Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOperating SystemsUNIX Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here!
  #1  
Old December 29th, 2004, 12:02 AM
izza_azhar izza_azhar is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 49 izza_azhar User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 h 33 m 57 sec
Reputation Power: 4
loop shell for beginners

i'm new in shell programming.
let say i have this file in directory
file1.txt.
file2.txt
sample1.txt
sample2.txt

so,i want to move file that begin with name"file" to another directory.so how is it?
help me please

Reply With Quote
  #2  
Old December 30th, 2004, 06:52 AM
christo's Avatar
christo christo is offline
Introspective
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Nov 2001
Location: London, UK
Posts: 3,296 christo User rank is Second Lieutenant (5000 - 10000 Reputation Level)christo User rank is Second Lieutenant (5000 - 10000 Reputation Level)christo User rank is Second Lieutenant (5000 - 10000 Reputation Level)christo User rank is Second Lieutenant (5000 - 10000 Reputation Level)christo User rank is Second Lieutenant (5000 - 10000 Reputation Level)christo User rank is Second Lieutenant (5000 - 10000 Reputation Level)christo User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 3 Days 1 h 5 m 42 sec
Reputation Power: 101
Send a message via ICQ to christo Send a message via Yahoo to christo
Quote:
Originally Posted by izza_azhar
i'm new in shell programming.
let say i have this file in directory
file1.txt.
file2.txt
sample1.txt
sample2.txt

so,i want to move file that begin with name"file" to another directory.so how is it?
help me please


Dude, you don´t have to write a programme to do this. These jobs can usually be done on the command line. I don´t have a unix terminal handy, so I can´t test these commands, but to move all the files beginning with ´file´into the directory ´/tmp´ you need to use something like:

ls -al | grep "file" | xargs mv /tmp

or to run recursively. use the find command with exec:

find . -name "file*" -exec mv /tmp {} \;

Note, I havn´t tested these, so have a play on some dummy files & directories first

christo

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsUNIX Help > loop shell for beginners


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway