Advertisement

05.11.2006 at 05:14PM PDT, ID: 21847701
[x]
Attachment Details

BASH Script to move files

Asked by steve212 in Linux Programming

Tags: script, bash, move, files

Sort of new to scripting, but here's what I want to do.  

I've got a lot of files that get dumped into a single directory every morning.  These file names only differ by their first four characters:

abcd-samesamesame
dcba-samesamesame
1234-samesamesame (etc.etc)

I have directories for abcd, dcba, 1234, etc.  I'd like a script that takes anything starting with abcd, and automatically dump it into the abcd directory.  Here's what I've got started:

#!/bin/sh

DUMDIR="/tftpimage"
FILE="abcd-*"

cd /tftpimage/configs
mv $FILE $DUMDIR/configs/abcd/

Is there a way to have:

FILE="first four characters of the filename"

 and then

mv $FILE $DUMDIR/configs/"first four chars...."

Hope that makes sense....?
Start Free Trial
[+][-]05.11.2006 at 06:54PM PDT, ID: 16664116

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Linux Programming
Tags: script, bash, move, files
Sign Up Now!
Solution Provided By: brettmjohnson
Participating Experts: 5
Solution Grade: A
 
 
[+][-]05.11.2006 at 08:47PM PDT, ID: 16664630

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.11.2006 at 11:31PM PDT, ID: 16665136

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.12.2006 at 02:02AM PDT, ID: 16665677

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.12.2006 at 12:18PM PDT, ID: 16670406

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.14.2006 at 05:22AM PDT, ID: 16677344

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.14.2006 at 10:33PM PDT, ID: 16680045

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.15.2006 at 01:50AM PDT, ID: 16680647

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.15.2006 at 01:55AM PDT, ID: 16680679

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.15.2006 at 03:49AM PDT, ID: 16681171

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.15.2006 at 10:30PM PDT, ID: 16687822

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.15.2006 at 11:06PM PDT, ID: 16687965

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]05.16.2006 at 02:23AM PDT, ID: 16688866

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]05.17.2006 at 12:33PM PDT, ID: 16702677

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32