![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Define an alias with an embeded awk command ?? | jfortes | Shell Programming and Scripting | 5 | 06-05-2007 01:03 PM |
| Export command giving Variable Name vs the Value set for the Variable | ParNone | UNIX for Dummies Questions & Answers | 2 | 04-03-2006 11:43 AM |
| define length of variable | cbarker | UNIX for Dummies Questions & Answers | 10 | 04-01-2005 12:42 PM |
| foreach command ?! | geoquest | UNIX for Dummies Questions & Answers | 5 | 05-20-2002 05:11 PM |
| Using Grep to Define a Variable | cspcspcsp | UNIX for Dummies Questions & Answers | 1 | 10-12-2001 12:22 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Hello,
I just want to know how If it's possiple to define 2 variable using foreach command ??? I have directory inside that directory around 1000 file, I want to rename all of this files to something I have it in a list. Example :- ------This is what in my directory---------- d1 d2 d3 d4 d5 ------------------------------------------------------ I have a LIST which containe the new naming "more new_name" and I have this omd1 omd2 omd3 omd4 omd5 I tried to do crazy way to done it :- # ls mydirectory >> old_name # foreach file (`more old_name`) file2 (`more new_name`) mv $file $file2 end I know this is crazy but I don't know how to do it Please do help me ![]() |
|
|||||
|
:%s/^/mv /g
this is a command mode operation of the vi editor. open any file in the vi editor press ESC once and type : you will get this prompt on the bottom left of your screen %s is for substitution. ^ is a special symbol which denotes the beginning of each line "mv " please note there is a space after mv is the string to be substituted and g is for replacing all the instances g is of no use here as there will be only one beginning of the sentence in each line, but if there are multiple instances of the search string ( in this case "^"), the option g is used to replace all the instances. if not given, then only the first instance of the search string in each line will be replaced. asif |
|
||||
|
Re: How to define two variable in foreach command??
Quote:
well from what your example says why dont you just do it this way. #! /bin/ksh cd (path to your directory here) for i in `ls`; do mv $i om$i done but then again. maby im not understanding your question. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|