One line to copy to do a rootfs


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting One line to copy to do a rootfs
# 1  
Old 12-25-2012
One line to copy to do a rootfs

Code:
[lyang0@intel]$ ls
bin  boot  dev  etc  home  lib  lib64  media  mnt  opt  proc  root  sbin  sys  tmp  usr  var guest_rootfs

I want to copy all the directory to guest_rootfs except "/bin /usr /var /tmp /sys and /guest_rootfs itself " with one line
# 2  
Old 12-25-2012
try:
Code:
for i in /* ; do echo $i | grep -q -E "/bin$|/usr$|/var$|/tmp$|/sys$|/guest_rootfs$" || mv "$i" /guest_rootfs ; done

# 3  
Old 12-25-2012
Quote:
Originally Posted by rdrtx1
try:
Code:
for i in /* ; do echo $i | grep -q -E "/bin$|/usr$|/var$|/tmp$|/sys$|/guest_rootfs$" || mv "$i" /guest_rootfs ; done

only for directory
# 4  
Old 12-25-2012
try:
Code:
for i in /* ; do echo $i | grep -q -E "/bin$|/usr$|/var$|/tmp$|/sys$|/guest_rootfs$" || { [[ -d "$i" ]] && mv "$i" /guest_rootfs ; } ; done


Last edited by Franklin52; 12-26-2012 at 11:41 AM.. Reason: code tags
# 5  
Old 12-26-2012
In bash or ksh:
Code:
cp -a /!(bin|usr|var|tmp|sys|guest_roots)/ /guest_roots
mv /!(bin|usr|var|tmp|sys|guest_roots)/ /guest_roots


Last edited by binlib; 12-26-2012 at 12:05 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Copy Column Value Of Next Line Into Current Line

Hello All, I am looking for help to achieve the following: Here is the data set 1757890237|42|55570025|1468796400|0 1757890237|32|55570025|1471474800|0 1757890237|54|55570025|1474153200|1476745200 1757890237|34|55570026|1468796400|0 1757890237|44|55570026|1471474800|0... (7 Replies)
Discussion started by: angshuman
7 Replies

2. Shell Programming and Scripting

Copy some line and paste it after some line in same file

Hi, I want to know how I can copy line 6th to 10th and paste it after 17th line in same file. Thanks, Biplab (19 Replies)
Discussion started by: Biplab
19 Replies

3. Red Hat

where to get redhat's guest's rootfs image

Hi experts I can't find a redhat's rootfs image for guest, where can find it Lei (2 Replies)
Discussion started by: yanglei_fage
2 Replies

4. UNIX for Dummies Questions & Answers

vim copy line and paste at the beginning, middle, and end of another line

How would you do vim copy line and paste at the beginning, middle, and end of another line. I know yy copies the whole line and p pastes the whole line, but on its own separate line. Sometimes I would like to copy a line to the beginning, middle, or end of another line. I would think this would be... (3 Replies)
Discussion started by: cokedude
3 Replies

5. Shell Programming and Scripting

Copy a field into n line in another place

I have a file contains 100 section (here i show 2 section of that); i want to replace date from 1st & 2nd field of 1st line of each section (1st line of each section is header and the other lines are body) and merg them into one field, then copy it on 7th field of the lines in each section... (17 Replies)
Discussion started by: oreka18
17 Replies

6. UNIX for Dummies Questions & Answers

rootfs query

Hi Guys actually I have installed the library of qt on my desktop with the help of a blog and after the installation the following thing is written in the blog , which I didn't mean , so please help me out of it. the code is: Build filesystem, copy necessary Qt libraries to the filesystem... (1 Reply)
Discussion started by: piyush011
1 Replies

7. Shell Programming and Scripting

Read and copy xml line by line and preserve tab?

I'm trying to read an xml file and copy it line by line to another file and want to preserve the tabs. What i'm trying to do is if I get to a certain line in the xml, I'm going to check to see if the next line is specifically what I want. If it's not, then I want to insert a single line of text... (4 Replies)
Discussion started by: DeuceLee
4 Replies

8. UNIX for Dummies Questions & Answers

copy a line from one file to another

I like to know what unix command i can use to append the second line of file #1 to the end of file #2 so that it performs the following. Thanks in advance. The purpose of this is to keep track of another log file (from crontab) that i have which the log content is flushed every 5 minutes so that... (5 Replies)
Discussion started by: shingpui
5 Replies

9. Shell Programming and Scripting

Copy first word of line

Usually I find the answers to my beginner-script-problems here in this forum but this time I had no luck so far...:( I want to modify a Japanese vocabulary file to import it into granule. Every line looks like this: I would like to have it like this: The lenght of the words always differ,... (2 Replies)
Discussion started by: shusai
2 Replies

10. Shell Programming and Scripting

Perl script to search a line and copy it to another line

Hi I have a log file (say log.txt). I have to search for a line which has the string ( say ERROR) in the log file and copy 15 lines after this into another file (say error.txt). Can someone give me the code and this has to be in PERL Thanks in advance Ammu (3 Replies)
Discussion started by: ammu
3 Replies
Login or Register to Ask a Question