Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I need to copy and rename (and then edit) a group of files in the /etc/sysconfig/network-scripts folder. The files are ifcfg-eth1:*

I have ifcfg-eth1 through ifcfg-eth1:121 but need to extend with more addresses, so I want to copy e.g ifcfg-eth1:22 and ifcfg-eth1:23 into ifcfg-eth1:122 and ifcfg-eth1:123 and then edit the copy.

I know how to edit, but not how to copy and rename. Found a lot of renaming info on this site, but I think I don't get the : part right...

How do I handle filenames including ":" ??

share|improve this question
1  
There's nothing special about : in a filename (except that Windows FAT filesystem doesn't allow that character) –  frostschutz Jul 5 '13 at 11:45
add comment

2 Answers 2

up vote 4 down vote accepted

Not sure if I understand your question right, but in Bash this could work:

for n in {22..99} ; do cp "ifcfg-eth1:$n" "ifcfg-eth1:1$n"; done

That would copy ifcfg-eth1:22 through ifcfg-eth1:99 to ifcfg-eth1:122 through ifcfg-eth1:199.

I'm not sure why you would use such files. If this is about ethX:Y aliases, you no longer need them. You can just ip addr add to the main interface. So maybe you should take a step back and ask a question about the problem you're actually trying to solve.

share|improve this answer
    
Thanks, this helped! And I will consider your recommendation about "ip addr add" –  rookie Jul 5 '13 at 12:42
    
Thanks for the tip as well regarding the ip addr add I wasn't aware of this change either. –  slm Jul 5 '13 at 13:31
add comment

It should be as simple as mv "ifcfg-eth1:xx" "ifcfg-eth1:yy"

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.