LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices



Reply
 
Search this Thread
Old 03-07-2005, 10:29 AM   #1
RDove
LQ Newbie
 
Registered: Jul 2004
Posts: 22

Rep: Reputation: 16
md5


I wrote a script to make a file called filename.md5 on each file it finds of the type *.bin. Here is the code:

Code:
#!/bin/sh
OLDIFS="$IFS"
IFS='
'

for i in $(find "/home/cisco" -iname *.bin);
do
 md5sum $i >> md5sum.log
 md5sum $i > $i.md5
done
I'd like to take this md5 file and move it to the folder its located in plus up one directory to 'md5'. So for example:

mkdir $i-directory-only/md5
mv $i.md5 $i-directory-only/md5

Whats the easiest way to do this?
 
Old 03-07-2005, 10:38 AM   #2
keefaz
Senior Member
 
Registered: Mar 2004
Distribution: Slackware
Posts: 4,617

Rep: Reputation: 136Reputation: 136
mkdir -p $i-directory-only/md5
mv $i.md5 $i-directory-only/md5
 
Old 03-07-2005, 11:04 AM   #3
RDove
LQ Newbie
 
Registered: Jul 2004
Posts: 22

Original Poster
Rep: Reputation: 16
I think the problem is that when I use find, it prints out the fille path plus file. Example:

/home/cisco/test/test/i386/c600-120-mz.bin

I need to some how get rid of the c800-120-mz.bin so I can use /home/cisco/test/test to make a directory and stuff.
 
Old 03-07-2005, 11:22 AM   #4
keefaz
Senior Member
 
Registered: Mar 2004
Distribution: Slackware
Posts: 4,617

Rep: Reputation: 136Reputation: 136
You could use dirname bash function
dir=$(dirname $i)
echo $dir
 
  


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
c++ md5 develinux Programming 2 02-28-2009 11:38 AM
what is MD5... JT13 Linux - General 2 06-11-2005 07:31 PM
using iso.md5 and iso.md5.asc Tyir Linux - Newbie 3 07-11-2004 12:45 AM
Md5 LinuxSeeker Linux - General 4 03-15-2004 06:01 PM
md5 vehemon *BSD 1 07-22-2003 09:14 PM


All times are GMT -5. The time now is 01:33 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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration