LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
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 08-19-2012, 08:55 PM   #1
gingernate
LQ Newbie
 
Registered: Aug 2012
Distribution: Ubuntu 12.04LTS
Posts: 20

Rep: Reputation: Disabled
Question Command to move file from one dir to another


I need to move binutils-2.22.tar.bz2 from the Downloads dir to /mnt/lfs/sources. Here is what i have tried;



nathan@nathan-linux:~/Downloads$ mv /Downloads/binutils-2.22.tar.bz2 /mnt/lfs/sources
mv: cannot stat `/Downloads/binutils-2.22.tar.bz2': No such file or directory


When i cd to Downloads and ls i get this;

nathan@nathan-linux:~/Downloads$ ls
autoconf-2.68.tar.bz2 lfs-bootscripts-20120229.tar.bz2
automake-1.11.3.tar.xz libpipeline-1.2.0.tar.gz
bash-4.2.tar.gz libtool-2.4.2.tar.gz
binutils-2.22.tar.bz2

So the file does exist.... So what am i missing?


EDIT: I have tried to use GUI and i cant because i do not have proper permissions to move from main user to my LFS(linux from scratch) user

Last edited by gingernate; 08-19-2012 at 08:56 PM.
 
Old 08-19-2012, 09:06 PM   #2
byannoni
Member
 
Registered: Aug 2012
Location: /home/byannoni
Distribution: Arch
Posts: 128

Rep: Reputation: 36
Quote:
Originally Posted by gingernate View Post
mv /Downloads/binutils-2.22.tar.bz2 /mnt/lfs/sources
You don't need a / for files in the current directory.

Do this:
Code:
mv ~/Downloads/binutils-2.22.tar.bz2 /mnt/lfs/sources
 
1 members found this post helpful.
Old 08-19-2012, 09:07 PM   #3
gingernate
LQ Newbie
 
Registered: Aug 2012
Distribution: Ubuntu 12.04LTS
Posts: 20

Original Poster
Rep: Reputation: Disabled
THANK YOU!!! Worked like a charm!
 
Old 08-19-2012, 09:17 PM   #4
gingernate
LQ Newbie
 
Registered: Aug 2012
Distribution: Ubuntu 12.04LTS
Posts: 20

Original Poster
Rep: Reputation: Disabled
Hey is there anyway to move all these files?

nathan@nathan-linux:~/Downloads$ ls
automake-1.11.3.tar.xz libpipeline-1.2.0.tar.gz
bash-4.2.tar.gz libtool-2.4.2.tar.gz
bison-2.5.tar.bz2 linux-3.2.6.tar.xz
bzip2-1.0.6.tar.gz lxterminal.desktop
check-0.9.8.tar.gz m4-1.4.16.tar.bz2
coreutils-8.15.tar.xz make-3.82.tar.bz2
dejagnu-1.5.tar.gz man-db-2.6.1.tar.gz
diffutils-3.2.tar.gz man-pages-3.35.tar.gz
e2fsprogs-1.42.tar.gz mpc-0.9.tar.gz
expect5.45.tar.gz mpfr-3.1.0.tar.bz2
file-5.10.tar.gz ncurses-5.9.tar.gz
findutils-4.4.2.tar.gz patch-2.6.1.tar.bz2
flex-2.5.35.tar.bz2 perl-5.14.2.tar.bz2
gawk-4.0.0.tar.bz2 procps-3.2.8.tar.gz
gcc-4.6.2.tar.bz2 psmisc-22.15.tar.gz
gdbm-1.10.tar.gz readline-6.2.tar.gz
gettext-0.18.1.1.tar.gz sed-4.2.1.tar.bz2
glibc-2.14.1.tar.bz2 shadow-4.1.5.tar.bz2
gmp-5.0.4.tar.xz sysklogd-1.5.tar.gz
grep-2.10.tar.xz sysvinit-2.88dsf.tar.bz2
groff-1.21.tar.gz tar-1.26.tar.bz2
gzip-1.4.tar.gz tcl8.5.11-src.tar.gz
iana-etc-2.30.tar.bz2 texinfo-4.13a.tar.gz
inetutils-1.9.1.tar.gz udev-181.tar.xz
iproute2-3.2.0.tar.xz udev-config-20100128.tar.bz2
kbd-1.15.2.tar.gz util-linux-2.20.1.tar.bz2
kmod-5.tar.xz vim-7.3.tar.bz2
less-444.tar.gz xz-5.0.3.tar.bz2
lfs-bootscripts-20120229.tar.bz2 zlib-1.2.6.tar.bz2

Last edited by gingernate; 08-19-2012 at 09:22 PM.
 
Old 08-19-2012, 09:24 PM   #5
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142
You mean like
Code:
mv ~/Downloads/* /path/to/destination/dir/
?
 
1 members found this post helpful.
Old 08-19-2012, 09:28 PM   #6
gingernate
LQ Newbie
 
Registered: Aug 2012
Distribution: Ubuntu 12.04LTS
Posts: 20

Original Poster
Rep: Reputation: Disabled
suicidaleggroll, YESSSS!!!!!!!!!!! thanks so much!
 
Old 08-20-2012, 01:57 PM   #7
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Arch + Xfce
Posts: 6,852

Rep: Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037
Please use ***[code][/code] tags*** around your code and data, to preserve formatting and to improve readability. Please do not use quote tags, bolding, colors, or other fancy formatting.

Code:
/Downloads/binutils-2.22.tar.bz2
When a pathname starts with "/" it signifies the absolute path to the file, starting from the system root. So this is looking for the file in "rootdir > downloads", not "rootdir > home > user > Downloads", the directory it's actually in.

If you are already in the directory with the file, you don't need to use the full path. Just use the relative path. Naming the file itself alone is usually enough, or alternately you can prefix it with ".", which means the current directory (and ".." means the parent directory).

Also, "~" is a pathname shortcut for your home dir, so you can include it instead of the "/home/user" part of the pathname. You could also use the $HOME variable, which contains the same string.

So any of these should work to move the file, assuming you are currently in the Downloads directory:
Code:
mv Downloads/binutils-2.22.tar.bz2 /mnt/lfs/sources
mv ./Downloads/binutils-2.22.tar.bz2 /mnt/lfs/sources
mv ~/Downloads/binutils-2.22.tar.bz2 /mnt/lfs/sources
mv $HOME/Downloads/binutils-2.22.tar.bz2 /mnt/lfs/sources
mv /home/user/Downloads/binutils-2.22.tar.bz2 /mnt/lfs/sources

To work with multiple files at once, have a look at globbing:

http://mywiki.wooledge.org/glob
http://wiki.bash-hackers.org/syntax/expansion/globs


Finally, it's also vital to understand how the shell handles arguments and whitespace. If a filename contains whitespace you'll need to quote or backslash it:
http://mywiki.wooledge.org/Arguments
http://mywiki.wooledge.org/WordSplitting
http://mywiki.wooledge.org/Quotes

Last edited by David the H.; 08-20-2012 at 02:01 PM. Reason: minor cleanup & wording
 
  


Reply



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
[SOLVED] command to cut all file and dir cnt Linux - Server 2 08-24-2011 05:59 AM
Shell Script for Identifying the file and zip all files, move the files to Target Dir gvenkat Linux - Newbie 3 05-07-2011 10:53 AM
Command to display /dir, /dir/sub, /dir/sub/files knockout_artist Linux - Newbie 9 10-25-2007 02:57 PM
Move file command? oldrelac Linux - Newbie 10 08-08-2003 11:58 AM
When I try to move a file to a dir it says No Space Left on Device. Help KrazyKid Linux - Software 1 06-16-2002 09:06 PM

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

All times are GMT -5. The time now is 05:11 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
Open Source Consulting | Domain Registration