Visit Our UNIX and Linux User Community

cp -p /home/* home/exp/*.date not working please help

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting cp -p /home/* home/exp/*.date not working please help
# 1  
Old 03-03-2011
cp -p /home/* home/exp/*.date not working please help


---------- Post updated at 01:51 AM ---------- Previous update was at 01:50 AM ----------

Not working

---------- Post updated at 02:04 AM ---------- Previous update was at 01:51 AM ----------

cp -p /home/* home/exp/*.`date`

i am using this
# 2  
Old 03-03-2011
I'm not sure what you're even trying to do with multiple wildcard and NO destination directory given. Copy files into multiple destinations or what? cp doesn't do that, it takes one destination.

What files are you trying to copy, from what source, to what destination? Be specific.
# 3  
Old 03-03-2011
trying to copy a list of files from one directory to another with date stamp

---------- Post updated at 02:07 AM ---------- Previous update was at 02:05 AM ----------

source /home :: all files
destination /home/exp
# 4  
Old 03-03-2011
Try this,
ls /home | awk '/^-/{print $NF}' | while read file; do echo cp "$file" /home/exp/"$file.`date '+%d%m%Y'`"; done

Last edited by pravin27; 03-03-2011 at 04:24 AM..
# 5  
Old 03-03-2011
I'm still not completely sure I understand what you want. You're copying multiple directories into one destination directory, but need to rename the directories in the process? You can't put a * in the destination like that, this isn't like DOS: The shell splits * for you before cp is even run, so you end up inputting stuff into cp that doesn't make sense if you * for things that don't exist yet.

I think you're going to have to split it into seperate cp calls.

for DIR in /home/*
        # Don't copy exp into exp/exp-timestamp!  It'd copy the copied copy copies!
        [ "$DIR" == "/home/exp" ] && continue

        NAME=`basename "$DIR"`
        cp -p "/home/${NAME}" "/home/exp/`date`-${NAME}"

Last edited by Corona688; 03-03-2011 at 06:30 PM.. Reason: missing backtick
This User Gave Thanks to Corona688 For This Post:

Previous Thread | Next Thread
Test Your Knowledge in Computers #96
Difficulty: Easy
Unix and Unix-like operating systems are a family of computer operating systems that are derived from the original Unix System developed at Xerox Park.
True or False?

10 More Discussions You Might Find Interesting

1. What is on Your Mind?

The C64 is back, this time full-sized with a working keyboard for the dedicated retro home-computer

Retro Games has announced that the C64 is back, this time full-sized with a working keyboard for the dedicated retro home-computer fan, available December 2019. See also: CNN: Iconic 80s computer The Commodore 64 to return with fully-functional keyboard YouTube: The C64 | Trailer ... (2 Replies)
Discussion started by: Neo
2 Replies

2. Solaris

New Oracle Home

How do I set ORACLE_HOME location? When I type echo $$ORACLE_HOME it gives me /u01/app/oracle//product/10.2.0/dbhome_1 which has been deleted. I just installed Oracle 11g and this is supposed to be a new oracle home /u01/app/oracle/product/11.2.0/dbhome_1 Any help from the community... (21 Replies)
Discussion started by: newborndba
21 Replies

3. Solaris

how to change /export/home/user dir to /home /user in solaris

Hi all i am using solaris 10, i am creating user with useradd -d/home/user -m -s /bin/sh user user is created with in the following path /export/home/user (auto mount) i need the user to be created like this (/home as default home directory ) useradd -d /home/user -m -s /bin/sh... (2 Replies)
Discussion started by: kalyankalyan
2 Replies

4. Programming

how to simulate "mkdir -p /home/blah1/blah2/blah3" in "c" where only /home exist

I'm trying to make use of mkdir(char *pathname, S_IRWXU) to create the directories. but it only creates one directory at a time. so I have to separate the tokens for "/home/blah1/blah2/blah3" as "home blah1 blah2 blah3" using delimiter "/", but it is again hectic to create such directory... (8 Replies)
Discussion started by: platinumedge
8 Replies

5. UNIX for Dummies Questions & Answers

extract a part of a path like (input: /etc/exp/home/bin ====> output: exp)

Hi, I need to make some extraction . with the following input to get the right output. input: /etc/exp/home/bin ====> output: exp and input: aex1234 ===> output: ex Thanks for your help, (4 Replies)
Discussion started by: yeclota
4 Replies

6. UNIX for Dummies Questions & Answers

Adding date to oracle exp log

I want to add a date/time stamp to the front of each line in an oracle exp log file. I created a shell script: rm -f expTest.Pipe mknod expTest.Pipe p date "+%Y.%m.%d %T" nawk -f expTest.nawk expTest.Pipe > expTest.Tlog & exp userid=UID/PW@DB file=expTest.dmp log=expTest.log owner=OWNER 2>>... (1 Reply)
Discussion started by: KrisOracleGuy
1 Replies

7. Shell Programming and Scripting

Working with multiple home directories.

I need to rename a directory in every home directory on a given workstation. I am a newb to scripting so maybe thats why I cant exactly figure out how to correctly do this. The first thing I need to be able to do to write this script is figure out how to list all the directorys (these are not... (11 Replies)
Discussion started by: trey85stang
11 Replies

8. Programming

HOME env

Do you know shell in Linux without HOME env. Best regards, Iliyan Varshilov (1 Reply)
Discussion started by: ilko_partizan
1 Replies

9. Shell Programming and Scripting

$HOME is not getting it's value.

#!/bin/ksh while read line < elig_jobs.txt do #Gets the field from the elig_jobs.txt file that has the input location path. INPUTD=`echo "$line" | cut -c240-289` (ex: $HOME/2005) echo inputdirectory: $INPUTD (this prints $HOME/2005) I want it to print /data/user/2005... (4 Replies)
Discussion started by: radhika
4 Replies

10. IP Networking

home network not working!

i just linked 2 100MHz Linux kernel 2.4.2 boxes togeather using a direct cable connection, on two 3Com PCI network cards, using the EtherLink III chipset. Unfortuanately, when I boot both PCs, i get a loading interface: eth0 for five minutes, then a failed flag. No networking suppt. in windows,... (2 Replies)
Discussion started by: boris888
2 Replies

Featured Tech Videos