LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 09-13-2014, 11:36 PM   #16
nyloc
Member
 
Registered: Aug 2007
Location: Melbourne
Posts: 111

Original Poster
Rep: Reputation: 17

This what my test code looks like

testdir="temp"
mkdir $testdir
GLOBIGNORE="*.jpg"
mv *.* $testdir


When I used mv * $testdir I got the move into a subdirectory of itself error message. I figure * is interepted as everything in the dir whereas *.* is interpreted as all files in the dir.
 
Old 09-14-2014, 12:21 AM   #17
nyloc
Member
 
Registered: Aug 2007
Location: Melbourne
Posts: 111

Original Poster
Rep: Reputation: 17
"Bug ? That's not a bug that's a feature !"
 
Old 09-14-2014, 07:38 AM   #18
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 6,552

Rep: Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872
Not a bug, glob * works for files and directories

You could use find maybe, like
Code:
testdir="temp"
mkdir $testdir
find . -maxdepth 1 -type f ! -name "*.jpg" -print0 | xargs -0 mv -t $testdir
 
Old 09-14-2014, 10:17 PM   #19
nyloc
Member
 
Registered: Aug 2007
Location: Melbourne
Posts: 111

Original Poster
Rep: Reputation: 17
Finally got it to run without errors. I tried a different search in google and found this website

http://unix.stackexchange.com/questi...attern-in-bash

from which I found these two options for testing for the presence of one or more files of type whatever (JPG jpeg)


shopt -s nullglob
set -- *.txt
if [ "$#" -gt 0 ]; then
./script "$@" # call script with that list of files.
fi



$ ls
file1.pl file2.pl

# a failure
$ stat -t -- *.txt >/dev/null 2>&1
$ echo "$?"
1

# a success
$ stat -t -- *.pl >/dev/null 2>&1
$ echo "$?"
0

I used the first one and no more error messages from the rename command, also used it in the move to the other directory to stop the error I was getting if there were no files to move.
 
  


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
LVM - creating extra logical volumes (using extra space outside LVM) rhbegin Linux - Server 1 01-30-2013 07:08 PM
Bash problem : -bash: [: /bin/bash: unary operator expected J.A.X Linux - Software 1 09-22-2011 05:52 AM
Remove extra new lines (BASH) akamikeym Programming 9 07-15-2010 10:56 AM
LXer: Fedora's Extra Packages for Enterprise Linux the Extra Mile LXer Syndicated Linux News 0 06-20-2008 10:10 PM
bash: extra stuff in brace expansion jhwilliams Programming 4 09-07-2007 02:44 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

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