LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
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 02-28-2012, 03:23 PM   #1
Dougj75
LQ Newbie
 
Registered: Feb 2012
Posts: 8

Rep: Reputation: Disabled
Cool Echo Command


Hi All,

I apprecaite all the help with the last post. I finally got it to work as I needed. I have another question:
How can I create an echo command to confirm that I want the following file copied:
There are times that I need to create a back-up of multiple files but maybe not all of them at once. I want to be able to ask the user if they want to back this file up and if not I need it to go to the next one and do the same


cp file /sys/log/cfg/OLD/file.`date '+%Y%m%d'`;

cp file2 /sys/log/cfg/OLD/file2.`date '+%Y%m%d'`;

cp file3 /sys/log/cfg/OLD/file3.`date '+%Y%m%d'`;
 
Old 02-28-2012, 04:46 PM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
this has nothing to do with the echo command. Echo just prints out words.

If you want to ask a question you can do something like

Code:
echo Enter y or n
read YN
if [[ $YN == y ]]
then
  ...
fi
 
Old 02-28-2012, 08:09 PM   #3
weibullguy
ReliaFree Maintainer
 
Registered: Aug 2004
Location: Kalamazoo, Michigan
Distribution: Slackware-current, Cross Linux from Scratch, Gentoo
Posts: 2,812
Blog Entries: 1

Rep: Reputation: 259Reputation: 259Reputation: 259
You could also do something like this to keep the cursor at the end of the prompt and allow either case for the answer.
Code:
echo -n "Enter Y or N: "
read YN
if [[ $YN == y || $YN == Y ]];
then
    .....
fi
 
  


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
echo command vinothaa Linux - Newbie 5 06-05-2010 09:15 AM
echo command mohit_parihar Linux - General 3 01-12-2010 07:54 AM
Command echo Corrado Linux - Newbie 3 11-11-2009 07:44 PM
echo command s_hcl Linux - General 1 09-06-2006 06:27 AM
echo command peculiarity eallen Linux - General 3 02-11-2003 06:30 PM

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

All times are GMT -5. The time now is 06:28 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration