LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 03-07-2014, 06:38 AM   #16
Toutatis
Member
 
Registered: Feb 2013
Posts: 419

Rep: Reputation: Disabled
you can also use this


http://www.scarabee-software.net/en/download.html
 
Old 03-07-2014, 06:57 AM   #17
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 4,442

Original Poster
Rep: Reputation: 76
Quote:
Originally Posted by colucix View Post
If you use quotes the whole list is taken as a single word! To avoid problems with blank spaces, either change the IFS variable or use a while read loop, redirecting standard input from <(find Aver*).
I get
Code:
semoi@server:~/STORE1/Nonsoft/libros/chess/nuevo$ cat ren2.sh
while read INPUT
do
    echo "$INPUT"
done < (find Aver*)
semoi@server:~/STORE1/Nonsoft/libros/chess/nuevo$ ./ren2.sh
./ren2.sh: line 36: syntax error near unexpected token `('
./ren2.sh: line 36: `done < (find Aver*)'
semoi@server:~/STORE1/Nonsoft/libros/chess/nuevo$
What can the syntax error be?
 
Old 03-07-2014, 07:04 AM   #18
55020
Senior Member
 
Registered: Sep 2009
Location: Yorks. W.R. 167397
Distribution: Slackware
Posts: 1,307
Blog Entries: 4

Rep: Reputation: Disabled
RTFM. "Note that no space may appear between the < or > and the left parenthesis, otherwise the construct would be interpreted as a redirection."

In any case I would always prefer 'find Aver* | while read...' instead of 'while ... do ... done <(find...)' because it preserves left-to-right readability.

But then I wouldn't use while read at all... and if you're going to use find instead of ls, you might as well use -print0...
 
Old 03-07-2014, 07:27 AM   #19
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 4,442

Original Poster
Rep: Reputation: 76
Code:
done <(find Aver*)
still gets syntax error. I am using 'for i in Aver*' as suggested by Colucix. That worked. Damned filenames with spaces!
 
Old 03-07-2014, 07:40 AM   #20
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
Quote:
Originally Posted by stf92 View Post
Code:
done <(find Aver*)
It should be
Code:
done < <(find Aver*)
spaced as shown. The first < is input redirection, whereas <(command) is process substitution.
 
1 members found this post helpful.
Old 03-07-2014, 07:54 AM   #21
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 4,442

Original Poster
Rep: Reputation: 76
Thank you very much, colucix.
 
Old 03-07-2014, 08:19 PM   #22
Richard Cranium
Senior Member
 
Registered: Apr 2009
Location: McKinney, Texas
Distribution: Slackware64 15.0
Posts: 3,860

Rep: Reputation: 2229Reputation: 2229Reputation: 2229Reputation: 2229Reputation: 2229Reputation: 2229Reputation: 2229Reputation: 2229Reputation: 2229Reputation: 2229Reputation: 2229
Quote:
Originally Posted by 55020 View Post
IFS is a game you can't win. Choose any random character that you *can't* have in your filenames. Are you feeling lucky?
I thought that was why there's a -print0 option to find.
 
Old 03-09-2014, 05:39 AM   #23
Martinus2u
Member
 
Registered: Apr 2010
Distribution: Slackware
Posts: 497

Rep: Reputation: 119Reputation: 119
Quote:
Originally Posted by stf92 View Post
Hi: I have a set of files under the same directory, all filenames beginning with the same prefix. How could I take away the prefix from all the filenames?

All I need is a way to do the operation for only one file, as then I could write a script to do the same within a loop.
I don't understand the complexity of replies in this thread. I habitually do that with one line of bash code:

Code:
for file in oldprefix* ; do mv $file newprefix${file#oldprefix} ; done
just have a look at the bash man page under "Parameter Expansion".
 
  


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
Help renaming files nandelbosc Programming 2 11-26-2009 08:24 AM
Renaming files leupi Linux - General 5 09-16-2008 04:22 AM
help renaming files please balistic Linux - Newbie 2 07-29-2007 04:35 PM
help renaming files balistic Linux - Newbie 4 07-29-2007 09:04 AM
Renaming files in one go anon318 Linux - Software 1 01-12-2004 02:16 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 02:32 PM.

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