[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: COMMAND FOR CP
From: |
Eric Blake |
Subject: |
Re: COMMAND FOR CP |
Date: |
Sat, 22 Apr 2006 14:50:49 +0000 |
> i have 4nos files which is to be copied to another name.
> i.e
>
> file1.GNT
> file2.GNT
> file3.GNT
> file4.GNT
> the above files to be copied at a stretch as
> file1.gnt
> file2.gnt
> file3.gnt
> file4.gnt
> I am using the following command
> cp *.GNT *.gnt whereas it is not working in LINUX
cp cannot do that. The glob (*.GNT or *.gnt) is expanded by the
shell, not by cp, and if the glob does not succeed, the shell
passes that part unchanged. So trying the following:
echo cp *.GNT *.gnt
would show that you are trying to execute
cp file1.GNT file2.GNT file3.GNT file4.GNT *.gnt
which doesn't make sense to cp since *.gnt does not
exist as a directory name.
However, if you are using bash or a similar shell, the
following construct would do what you desire:
for f in *.GNT; do cp "${f/.GNT}.gnt" ; done
--
Eric Blake