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 06-18-2010, 09:24 PM   #1
Dru-Jitsu
Member
 
Registered: Jun 2010
Posts: 38

Rep: Reputation: 15
Need some help


So I am taking an half online/ half go to school class. I am working on an assignment that is due tonight by midnight. I am kind of confused on this question and am waiting on an email from my instructor but only have 2.5 hrs left til it's done. Here is the question.

Use file globbing to copy all the files in the /labs/data directory that end with a .out to the lab07 directory. How many files are in the lab07 directory?

Ok so.... I put myself into the /labs/data dir

cd /labs/data

ls -l

when I ls -l into this directory. I don't see any files with that extension. Is there an easier way that I am missing such as. cp /labs/data *.out > lab07 ??? Someone help?

Last edited by Dru-Jitsu; 06-18-2010 at 09:25 PM.
 
Old 06-18-2010, 09:40 PM   #2
blue_print
Member
 
Registered: May 2010
Location: In world
Distribution: RHEL, CentOS, Ubuntu
Posts: 275
Blog Entries: 3

Rep: Reputation: 50
I don't think the command you tried have worked.

Before copying files, you will have to make sure that the files with the extensions .out are there or not in '/lab/data' directory. Then, have the following command to copy the files,

cp /labs/data/*.out /lab07/
 
Old 06-18-2010, 09:59 PM   #3
Dru-Jitsu
Member
 
Registered: Jun 2010
Posts: 38

Original Poster
Rep: Reputation: 15
I tried using the advice given. Now it tells me that the directory doesn't exist. Starting up the first thing I did was mkdir /lab07. I am really not to sure where to go from here.
 
Old 06-18-2010, 10:04 PM   #4
dxqcanada
Member
 
Registered: Sep 2006
Location: Canada
Distribution: Gentoo
Posts: 702

Rep: Reputation: 43
Ok ... so you are in the /labs/data directory ... and you run ls -l ... and you see no files that are blahblah.out ?

Hmmm .. try ls -a
 
Old 06-18-2010, 10:13 PM   #5
Dru-Jitsu
Member
 
Registered: Jun 2010
Posts: 38

Original Poster
Rep: Reputation: 15
Yes I tried both of those... I enter the directory cd /labs/data and then I ls -l or -a and I see nothing in there that ends with .out.

As for copying it over into my directory... what about this?

cp /labs/data/ned /labs/data/fred ~/labXX # now combine it together using file globing:

cp /labs/data/[nf]ed ~/labXX
 
Old 06-19-2010, 07:54 PM   #6
Dru-Jitsu
Member
 
Registered: Jun 2010
Posts: 38

Original Poster
Rep: Reputation: 15
I figured out the one from last night, now I am onto a new headache....


Use file globbing to copy all the files in the /labs/data directory that start with a c, d, or n into the lab07 directory. How many files are now located in the lab07 directory?

this is the command I am using
I am in my created directory lab07

cp /labs/data[c,d,n]~/lab07

I am getting a specified destination directory does not exist, I know it exists I am in it right now. Any help would be awesome.
 
Old 06-20-2010, 11:49 PM   #7
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,411

Rep: Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397
As this is homework, I'll just make a few suggestions (as per LQ rules)

1. you need a '/' between the dirname & filenames
2. you need space between src and target
3. Bookmark and read:
http://rute.2038bug.com/index.html.gz
http://tldp.org/LDP/Bash-Beginners-G...tml/index.html
http://www.tldp.org/LDP/abs/html/
 
  


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



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

All times are GMT -5. The time now is 06:17 AM.

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