LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
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 11-09-2015, 01:17 AM   #16
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751

There's a couple of options described here https://superuser.com/questions/1253...files-in-linux eg 'cmp -l' and xxd.
Maybe you can find a version of hexdiff http://manpages.ubuntu.com/manpages/...hexdiff.1.html to use
 
Old 11-09-2015, 02:26 AM   #17
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,007

Rep: Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191
Well after hearing why the script was created I have 2 suggestions:

1. Complete the script as it is a great learning experience for any future scripts you might create. Plus if you follow some of my advice above and save it for later, you can refer to it when you write your next script on things to do an good practice.

2. man rsync - this toll does basically exactly what you are looking for, but like most things it takes practice to be good at using the correct features

On a side note, I thought of another issue with your current script which would throw you all types of issues. If we assume we are in your home directory and one of the directory names you pas in is 'bin', the first issue is that 'bin' would have to be in the directory you are in. However, an ongoing issue would be if 'bin' also has a directory under it , we'll call it 'next_dir'. In your current code when you hit 'next_dir' you will use traverse on it, but because you use ls it will perform the following at the start of the while loop:
Code:
ls next_dir | | while read LSRESULTS
The issue is, 'next_dir' is not in the current directory or if it is you will get files from it and not the one you were looking for. This would mean if you are then to move the files, you may well now move files that were either already moved and cause a collision, or move files that should not be moved at all.

So I hope you stick with the script and am happy to help and answer more questions. Of course if time is an issue you may choose to use rsync, but like I said this is not necessarily a simple alternative.

Here are some other links which may assist in your script:

http://tldp.org/LDP/abs/html/
http://mywiki.wooledge.org/TitleIndex (Once you are better at scripting, I would work all the way through this site at your leisure)
 
  


Reply

Tags
foreach, sh, shell



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
simple shell script EOF error networkguy Linux - Newbie 5 09-21-2015 07:12 AM
Simple script , error catch arash8m Programming 1 05-24-2007 01:04 PM
Simple Shell Script Error SBN Programming 11 03-19-2007 06:18 PM
Can't seem to run a simple shell script error command not found each time SimonT Linux - Newbie 5 10-29-2006 06:31 AM
simple script but error ryedunn Programming 4 03-11-2004 07:02 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:00 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
Open Source Consulting | Domain Registration