Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - General
User Name
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.


  Search this Thread
Old 09-29-2005, 03:03 AM   #1
LQ Newbie
Registered: Feb 2005
Distribution: Fedora Core 3
Posts: 5

Rep: Reputation: 0
Bash script. help needed


I've written my first bash script but I ran into some problems.


ls -1A -- *.rar | while read FILE
echo "Doing file $FILE..."
unrar x "$FILE"
ls -1A -- *.avi | while read FILM
echo "Moving file $FILM..."
mv "$FILM" /home/tazthecat/films/"$FILM"
works, but only if the rar file is named *.rar, *.r01, etc.
If the filename is *.part1.rar, *.part2.rar, etc. it keeps extracting the file over and over again.
How do I tell script to stop if $FILE exist ?

Thanks in advance..
Old 09-29-2005, 08:49 AM   #2
Registered: Aug 2005
Distribution: Gentoo
Posts: 228

Rep: Reputation: 31
File test operators

It is part of a larger Guide: Advanced Bash-Scripting Guide

Good luck!
Old 09-30-2005, 02:54 AM   #3
LQ Newbie
Registered: Feb 2005
Distribution: Fedora Core 3
Posts: 5

Original Poster
Rep: Reputation: 0
thanks flower.Hercules for your response.

I have found out that instead of 'rar x *.rar' 'rar x -o- *.rar' -o- is to stop if file exists.

Here is another script I wrote to sort my download folder.


ls -1A -- *.zip *.rar *.gz *.bz2 2>/dev/null | while read RAR; do
echo "Moving file $RAR..."
mv -- "$RAR" /home/tazthecat/zip_bestanden/

ls -1A -- *.jpg *.jpeg *.gif 2>/dev/null | while read AFB; do
echo "Moving file $AFB..."
mv -- "$AFB" /home/tazthecat/Afbeeldingen/

ls -1A -- *.bin *.rpm *.sh *.run 2>/dev/null | while read EXE; do
echo "Moving file $EXE..."
mv -- "$EXE" /home/tazthecat/installers/

ls -1A -- *.doc *.sxw *.txt 2>/dev/null | while read TXT; do
echo "Moving file $TXT..."
mv -- "$TXT" /home/tazthecat/tekst_bestanden/
I have this file in ~/.gnome2/nautilus-scripts/ just change dir's to match your dir's. rightclick choose name of script.

Scripting is still hard for me, but I try try again......


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 On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
bash script help needed Henster Linux - General 4 08-21-2005 10:54 AM
Wrapper needed for BASH Script outspoken Programming 0 01-12-2005 10:04 AM
send automatic input to a script called by another script in bash programming jorgecab Programming 2 04-01-2004 01:20 AM
bash script - incrementing a filename in a script tslinux Programming 10 08-06-2003 12:58 AM
bash script prob: how can i tell the script that a 'dd' has finished? Frustin Linux - General 2 04-02-2003 06:34 AM > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 11:26 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration