LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
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-04-2012, 01:54 PM   #1
nyratoncito
LQ Newbie
 
Registered: Aug 2012
Posts: 3

Rep: Reputation: Disabled
New to Linux and have desire to learn more.


Hello everyone good to be here and find helpful tips on linux. I have been taking a Red Hat class and trying to figure some stuff out. I have few questions that can't find a fast solution to. For example my first question is:
How can I Copy all files with 3 characters then an x to a directory Main from /usr/lib (when you pipe it to wc properly you get 70 lines or files.

I have tried so many formats but can't get to copy these file to /home/Juser2/Final/Main

I am using centOS.

If anyone can help me please I will be Thankful.
 
Old 08-04-2012, 04:00 PM   #2
Elv13
Member
 
Registered: Apr 2006
Location: Montreal,Quebec
Distribution: Gentoo
Posts: 825

Rep: Reputation: 128Reputation: 128
the 3 first letter of files in /usr/lib are usually lib, so, "cp ./libc* /path/to/Main/" would work in most cases. But if it does not, regular bash syntax niceness wont be enough without trashing the line with a lot of chars. The better trick here would be to use ls, grep/egrep and xargs with a regular expression.
Code:
ls | grep -E "your regex here" | xargs -i cp -a {} /path/to/Main/
 
Old 08-05-2012, 03:20 PM   #3
nyratoncito
LQ Newbie
 
Registered: Aug 2012
Posts: 3

Original Poster
Rep: Reputation: Disabled
I had an email from one of the student in my class and he came with on simple code which is:
cp /usr/lib/???x* Final/Main/*
 
1 members found this post helpful.
Old 08-05-2012, 08:05 PM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,240

Rep: Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324
http://www.netlingo.com/word/tmtowtdi.php
 
Old 08-06-2012, 01:17 AM   #5
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,396
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
Quote:
Originally Posted by nyratoncito View Post
I had an email from one of the student in my class and he came with on simple code which is:
cp /usr/lib/???x* Final/Main/*
Given that this is a homework question, that is quite likely the definitive solution. Do you understand what the solution does?

--- rod.
 
Old 08-06-2012, 06:20 AM   #6
nyratoncito
LQ Newbie
 
Registered: Aug 2012
Posts: 3

Original Poster
Rep: Reputation: Disabled
Yes, I do understand what the solution does, which from the look of it was very simple to do and I was over-thinking it.
 
Old 10-12-2012, 05:29 PM   #7
eNux eLin
LQ Newbie
 
Registered: Oct 2012
Posts: 9

Rep: Reputation: Disabled
Please explain the purpose of the second asterisk in the above command "cp /usr/lib/???x* Final/Main/*"

Off topic can anyone explain how to google the characters /*
I've tried "/*" without success
 
Old 10-14-2012, 04:13 PM   #8
eNux eLin
LQ Newbie
 
Registered: Oct 2012
Posts: 9

Rep: Reputation: Disabled
Solved

see this thread for the second asterisks properties explanation . . .

http://www.linuxquestions.org/questi...ml#post4805602
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] simple script but not the desire answer why ? ratotopi Programming 5 01-18-2012 08:10 PM
desire to learn. Azraelthefallen00 LinuxQuestions.org Member Intro 2 08-27-2010 12:44 AM
Desire to install XP w/ Kubuntu already installed. MooMooMilk Linux - General 2 04-27-2007 02:50 AM
deep desire shukla_chanchal LQ Suggestions & Feedback 25 11-22-2005 06:51 PM
how can you install desire software on linux? paschim Linux - Software 6 09-01-2004 01:54 AM


All times are GMT -5. The time now is 02:47 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