LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 10-24-2017, 01:08 PM   #1
AnkitRauthan
LQ Newbie
 
Registered: Oct 2017
Posts: 6

Rep: Reputation: Disabled
Issue In Using Maxdepth


Hi, Friends I am pretty much a newbie in linux, and right now I am stuck in a very simple problem.

I am using a command to copy file from one place to another,but stuck within maxdepth.My code is:-

#!/bin/sh
find /home/user/etc/dir1/dir2/ -maxdepth 1 -mtime -1 -exec scp -r "{}" username@hostname:/home/user/etc/dir1/dir2/ \;
echo "done";

here the issue is that dir 2 has more directories inside of it,and those directories have file inside it.But when i copy using maxdepth 1 it also copy full dir2,but i only want directories which are inside it. so while using maxdepth 1.depth 0 is dir2 itself and then depth 1 is directories inside dir2.So i only want depth 1 and not depth 0.

So,can anybody quickly give me any sweet simple example and tell me that how to take particular depth only.
Thanks
Best Reagards
Ankit Rauthan
 
Old 10-24-2017, 01:20 PM   #2
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 5,690
Blog Entries: 3

Rep: Reputation: 2920Reputation: 2920Reputation: 2920Reputation: 2920Reputation: 2920Reputation: 2920Reputation: 2920Reputation: 2920Reputation: 2920Reputation: 2920Reputation: 2920
As mentioned in the other thread you do not want to use the -r option with scp

Please read on what it does:

Code:
man scp
 
1 members found this post helpful.
Old 10-24-2017, 01:24 PM   #3
AnkitRauthan
LQ Newbie
 
Registered: Oct 2017
Posts: 6

Original Poster
Rep: Reputation: Disabled
@Turbocapitalist, I just found out the answer.I have to use maxdepth with mindepth,and it will take care of it.Thanks for your earlier help though.That was the main part of my problem.And when you explain me the procedure,It was breeze.As said earlier,Thanks A ton mate.And yes i will read out what you said.
Best Regards
Ankit Rauthan.
 
Old 10-24-2017, 01:26 PM   #4
AnkitRauthan
LQ Newbie
 
Registered: Oct 2017
Posts: 6

Original Poster
Rep: Reputation: Disabled
The Code For Right Solution.
#!/bin/sh
find /home/user/etc/dir1/dir2/ -maxdepth 1 -mindepth 1 -mtime -1 -exec scp -r "{}" username@hostname:/home/user/etc/dir1/dir2/ \;
echo "done";
 
  


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
Is there software to find network issue? Possible packets dropped or similar issue xmrkite Linux - Software 7 03-17-2015 06:33 PM
[SOLVED] Cannot 'find "[" -maxdepth 1 -wholename "/usr/bin/[" ! \( -perm /g+w,o+w \)' standard_output Linux - General 5 09-13-2013 04:23 PM
[SOLVED] find maxdepth and print only the maxdepth matches cli Linux - Newbie 4 06-11-2013 12:36 PM
fedora4+cbq+maxdepth problem sumonhere Linux - Networking 1 03-17-2007 03:45 AM
Simulating mindepth, maxdepth in find subu_s Programming 1 04-11-2005 05:38 AM

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

All times are GMT -5. The time now is 11:16 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