Copy interactively - shell input


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Copy interactively - shell input
# 1  
Old 10-09-2008
Copy interactively - shell input

Hello,

I am making a script to copy files interactively from one directory to another using the "i" option because I dont want to overwrite the files.

cp -i *.html ./../otherdir/
cp: do you want to overwrite (y/n) ?


I used

cp -i *.html ./../otherdir/
ans='n'
read $ans


But the script is unable to pickup the value as "n" as a response to the
shell output -
cp: do you want to overwrite (y/n) ?
# 2  
Old 10-09-2008
try using "yes" command
read man page of yes
man yes
# 3  
Old 10-09-2008
yes|cp -i A B

would only give me "y" as an answer which means permission to overwrite.

I want to give "n" as an answer to the question since i dont want to overwrite -

cp : do you want to overwrite(y/n) ?

Is there some command oppsite to "yes"
# 4  
Old 10-09-2008
did you tried this??
Code:
yes no|cp -i A B

# 5  
Old 10-24-2008
Yes is only for affirmative answers , I want a negative answer so that the file being copied is not overwritten.

I used this - yes no|cp A B

is still overwriting file B with A.

If I give

yes no |cp -i A B

then interactive message comes.

overwrite ./a/1.txt? ki023b[/icvdev1/gr7885]>
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Copy data to new file based on input pattern

Hi All, I want to create a new file based on certain conditions and copy only those conditioned data to new file. Input Data is as it looks below. ORDER|Header|Add|32|32|1616 ORDER|Details1......... ORDER|Details2......... ORDER|Details3......... ORDER|Details4............ (10 Replies)
Discussion started by: grvk101
10 Replies

2. Shell Programming and Scripting

Read input txt while find copy

I have a text file called file.txt which has a list of file as shown below that i need to find and copy to a particular location. FILENAMES skter.pdf abcdf.sas tereen.lst abc12.txt i am using following code and it never works however i try it. cat file.txt | while read FILENAME;do find... (4 Replies)
Discussion started by: MILAN KUMAR
4 Replies

3. Shell Programming and Scripting

Input handling and formatting input to shell

i want to get input and depending on it create new commands for input to expect. But problem is that after giving date or month as 01-09 it is interpretation as 1-9 echo -n "ENTER DATE " read d1 echo -n "ENTER MONTH " read m1 echo -n "ENTER YEAR" read y1 o=1 i=1 d2=`expr $d1... (1 Reply)
Discussion started by: sagar_1986
1 Replies

4. UNIX for Dummies Questions & Answers

Unable to copy file using SCP (Input/output & Permission denied error)

Hi, I am facing issue while using scp. Source & target machines are Linux & HP-UX respectively. On target machine, if I fire the following command, I get error: Now if I try scp on another file, which is on the same source machine, it works fine. All directories and subdirectories... (2 Replies)
Discussion started by: Technext
2 Replies

5. Shell Programming and Scripting

shell script to take input from a text file and perform check on each servers and copy files

HI all, I want to script where all the server names will be in a text file like server1 server2 server3 . and the script should take servernames from a text file and perform copy of files if the files are not present on those servers.after which it should take next servername till the end of... (0 Replies)
Discussion started by: joseph.dmello
0 Replies

6. Shell Programming and Scripting

input username and password interactively

Hi guys, I am using Solaris 10 and we install IBM OnDemand server there. there's a command called arsload that we use to load document and query document too. I need to write a script to query document but when querying document, this command prompt for username then password. My question is... (3 Replies)
Discussion started by: markthien
3 Replies

7. Shell Programming and Scripting

Copy files from input file with dir structure

hi, I want to copy files from source directory based on input file (or output of previous command) and i want to have the SAME DIRECTORY STRUCTURE. Note that i will have other files and directories which i dont want to copy to destination. For example, dir source has following content:... (22 Replies)
Discussion started by: dragon.1431
22 Replies

8. Shell Programming and Scripting

Copy input to log file in perl

Can anyone please correct the code. I am trying to copy the user input to an output file log.txt: the script works fine but when I am trying to copy the user input error is generated. Thanks in advance. #!/usr/bin/perl $temp = "/home/log.txt"; $reply = ""; print 'Enter the code:... (1 Reply)
Discussion started by: sureshcisco
1 Replies

9. Shell Programming and Scripting

Copy input file based on condition

Hi, I am new to unix shell programming. I want to write a shell script for a functionality existing in mainframe system. I have one file as below as input 123456 &__987 &12yuq abcdef _ referes to blank condition:whenever the input file is having &__ ,it should be replaced... (4 Replies)
Discussion started by: charan0703
4 Replies

10. Shell Programming and Scripting

How to copy from standard input

I tried copy the output files from find command into a directory. Example, find / -name core 2>/dev/null | xargs cp???? I have known that we can use xargs to execute command lines from standard input but how to use it in this case. Or I can do something besides xargs. (2 Replies)
Discussion started by: lalelle
2 Replies
Login or Register to Ask a Question