trying to add an option to view before executing?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting trying to add an option to view before executing?
# 1  
Old 10-15-2007
trying to add an option to view before executing?

I am very new to scripting.

I have the following script:

for i in `ls -1 | grep $1 | grep -v $2`
do
x=`echo $i | sed 's/\.New/\.Old/g'`
echo mv $i DONE/$x
done

This is taking files from the directory I am in and changing the name from .New to .Old and then echoing the command to move it to a DONE directory.

So from here I want to know how can I add a little output that asks the user if what outputted to the screen is correct? And if it is go ahead and move and if not just cancel out.

Thank you for ANY replies!!
# 2  
Old 10-16-2007
Add this:
Code:
for i in `ls -1 | grep $1 | grep -v $2`
do
    x=`echo $i | sed 's/\.New/\.Old/g'`
    echo "Will now move $i to DONE/$x. OK?"
    read user_response
    case $user_response in
    "y"|"Y") echo mv $i DONE/$x;;
    *) echo "No changes made..."
    esac
done

# 3  
Old 10-16-2007
That worked awesome!
How can I make it so that it doesn't ask for each file but rather the entire list that is outputed?

Thanks again!
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. What is on Your Mind?

Moving from Desktop View to Mobile View

See attached video for a demo on how to move back and forth from the desktop view to the mobile view. Currently this only works for the home page, but I will work on some new PHP code in the future to make this work with the page we are currently on. Edit: The issue with making every page ... (2 Replies)
Discussion started by: Neo
2 Replies

2. Shell Programming and Scripting

How to add a Y/N option?

I want to be able to add to any script that gives the option to continue or not, after the the first loop thru and to keep giving you the option after the user answers "Y" then does their thing then gives that option again once done. I've been seeing examples online on how to do it, but not for it... (2 Replies)
Discussion started by: bud1738
2 Replies

3. UNIX for Dummies Questions & Answers

Executing a tar command with the --exclude option in a Debian shell script.

Hi All, I am trying to execute the following tar command with two --exclude options to suppress extract of the two directories specified. Do I need to single quote the directory paths ?? Many thanks for your help. The relevant code excerpt from the script is: cd /var/www/${SITE} ... (7 Replies)
Discussion started by: daveu7
7 Replies

4. Shell Programming and Scripting

Add option to fstab

I need as script (awk/sed?) to add noatime option to fstab. It should append ,noatime to whatever is in column 4 if noatime isn't already there, leaving comments alone. input: # /etc/fstab # Created by anaconda on Mon Oct 31 20:44:41 2011 # # Accessible filesystems, by reference, are... (5 Replies)
Discussion started by: pblumenthal
5 Replies

5. Shell Programming and Scripting

Executing a batch of files within a shell script with option to refire the individual files in batch

Hello everyone. I am new to shell scripting and i am required to create a shell script, the purpose of which i will explain below. I am on a solaris server btw. Before delving into the requirements, i will give youse an overview of what is currently in place and its purpose. ... (2 Replies)
Discussion started by: goddevil
2 Replies

6. Ubuntu

Add Option To Right Menu

hey all, I already installed nautilus-actions now , I want to add "print path" script(option) to the right context menu!.. I did : http://img853.imageshack.us/img853/6973/59818245.png http://img847.imageshack.us/img847/8758/37217230.png the script print located in... (2 Replies)
Discussion started by: eawedat
2 Replies

7. Shell Programming and Scripting

How do I add the option to change the path in a menu?

How do I add the option to change the path in a menu? I have this script. The user chooses a number and had the option of doing something, looking for log files etc. There is a possibility they might want to look at a different path other than what I have given them such as... (2 Replies)
Discussion started by: taekwondo
2 Replies

8. UNIX for Dummies Questions & Answers

How to add the landscape option...

to an existing print que? (1 Reply)
Discussion started by: NycUnxer
1 Replies

9. Windows & DOS: Issues & Discussions

How to add Win2000, Win Me option to Lilo menu?

Hi All, I have installed RH Linux 7.1, windows 2000 and windows ME in the same machine. There are two booting menu: Lilo: Linux Dos Dos : Windows2000 WindowsME If I want to use windowME, I need to boot lilo and choose dos and final choose windows ME. Have any... (3 Replies)
Discussion started by: wilsonchan1000
3 Replies
Login or Register to Ask a Question