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 01-08-2017, 04:15 AM   #1
c3n
LQ Newbie
 
Registered: Jan 2017
Posts: 3

Rep: Reputation: Disabled
Problem with scipt, use command sort, mv


I have a problem with writing a script that you want to sort files by extension in a subdirectory called extension.
I sort files from the /home/root1/nakosi and do not know how to use the command sort or mv to sort your files into subdirectories.
 
Old 01-08-2017, 04:21 AM   #2
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,519
Blog Entries: 4

Rep: Reputation: 3829Reputation: 3829Reputation: 3829Reputation: 3829Reputation: 3829Reputation: 3829Reputation: 3829Reputation: 3829Reputation: 3829Reputation: 3829Reputation: 3829
Welcome.

The mv utility needs as options a source file and a destination directory. The following moves foo.txt to another directory.

Code:
mv /home/me/some/dir/foo.txt /somewhere/else/.
Check the manual page, as it is a good reference. The -t option might be useful sometimes in a script.

Code:
man mv
Post the script as you have it or the individual steps that you have been testing so we can see where you are stuck.
 
1 members found this post helpful.
Old 01-08-2017, 05:41 AM   #3
c3n
LQ Newbie
 
Registered: Jan 2017
Posts: 3

Original Poster
Rep: Reputation: Disabled
Thanks is working

Maybe you know how to hide the mistake? mv: cannot stat ‘/home/root1/nakosi/*.php’: No such file or directory
 
Old 01-08-2017, 06:09 AM   #4
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 22,735

Rep: Reputation: 7556Reputation: 7556Reputation: 7556Reputation: 7556Reputation: 7556Reputation: 7556Reputation: 7556Reputation: 7556Reputation: 7556Reputation: 7556Reputation: 7556
that is called redirection, add:
2>/dev/null
at the end of the command
 
1 members found this post helpful.
Old 01-08-2017, 08:22 AM   #5
c3n
LQ Newbie
 
Registered: Jan 2017
Posts: 3

Original Poster
Rep: Reputation: Disabled
Thanks is working. This error has disappeared.
 
Old 01-08-2017, 08:28 AM   #6
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,519
Blog Entries: 4

Rep: Reputation: 3829Reputation: 3829Reputation: 3829Reputation: 3829Reputation: 3829Reputation: 3829Reputation: 3829Reputation: 3829Reputation: 3829Reputation: 3829Reputation: 3829
Quote:
Originally Posted by c3n View Post
This error has disappeared.
Well, technically just the error message has been hidden. The error causing it is still there. If you want to check for the existence of a file or directory before trying to move it, you can use the utility test with the -e, -f, or -d options.
 
1 members found this post helpful.
  


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
using the sort command castor0troy Linux - Newbie 6 04-23-2013 10:01 AM
[SOLVED] Bash "sort" command problem rt1870 Linux - Newbie 5 04-17-2013 07:12 AM
sort command coffee arabia Linux - Newbie 3 10-29-2010 05:10 PM
Sort command djfog Linux - Newbie 17 07-03-2008 03:05 AM
Need a shell scipt to get 2 variables per line and then run a command var 1 is over 5 abefroman Programming 2 02-18-2006 03:46 PM

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

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