LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
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 02-24-2010, 12:41 PM   #16
lt1776
LQ Newbie
 
Registered: Feb 2010
Posts: 13

Original Poster
Rep: Reputation: 0

Colucix,

Can you explain what the 'i' variable is doing in this code? I know that it works but i don't understand what is going on.

Quote:
for ((i=0; i < ${#orignames[*]} ; i++))
Specifically, I don't understand what this section means:
Quote:
i < ${#orignames[*]}
I understand that '${#orignames[*]}' returns the length of the array, but in don't understand what 'i < ${#orignames[*]}' means.

Also I assume that
Quote:
i++
means add 1 to the variable 'i' each time the loop runs. Is that correct?
 
Old 02-24-2010, 12:46 PM   #17
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
First, it sets i=0
Then, the loop runs as long as the test (i< stuff) is true ( "<" in this context means "less than" )

i++ does exactly what you guessed
 
1 members found this post helpful.
Old 02-24-2010, 01:52 PM   #18
lt1776
LQ Newbie
 
Registered: Feb 2010
Posts: 13

Original Poster
Rep: Reputation: 0
I like that. Thanks
 
Old 02-24-2010, 03:33 PM   #19
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,313

Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
sorry i havent read many of the responses but this seems to be close to what you want: [untested]
Code:
for item in "`paste old-file-names.txt new-file-names.txt`"
do
 mv "$item"
done
 
  


Reply



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
Renaming multiple files Changes Linux - Newbie 1 02-01-2009 09:58 PM
renaming multiple files yanchina12 Linux - Newbie 5 12-21-2007 07:56 AM
Combine multiple one column text file into one text file with multiple colum khairilthegreat Linux - Newbie 7 11-23-2007 01:31 PM
Steps needed to convert multiple text files into one master text file jamtech Programming 5 10-07-2007 11:24 PM
Renaming multiple files ajcns Linux - Newbie 2 01-19-2007 11:04 PM

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

All times are GMT -5. The time now is 01:32 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
Open Source Consulting | Domain Registration