Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 06-27-2012
Registered User
 
Join Date: Jul 2011
Posts: 20
Thanks: 3
Thanked 1 Time in 1 Post
Perl one liner to replace text

Not quite a unix question but problem in a perl command. Taking a chance if someone knows about the error


Code:
cat 1
a b c d
perl -p -e 's/a/b/g' 1
b b c d

What is the problem here??


Code:
perl -p -i -e 's/a/b/g' 1
Can't remove 1: Text file busy, skipping file.

Sponsored Links
    #2  
Old 06-27-2012
...@...
 
Join Date: Feb 2004
Location: NM
Posts: 9,646
Thanks: 164
Thanked 641 Times in 618 Posts
-i means "in place" But. It requires that the original file be removed and 1 is stdout to perl.
Sponsored Links
    #3  
Old 06-27-2012
Registered User
 
Join Date: Jul 2011
Posts: 20
Thanks: 3
Thanked 1 Time in 1 Post
Thanks for replying Jim, prompted by your explanation, I found that the file under consideration is owned by root. A 'user' owned files can be changed by the same command.

I tried
Code:
sudo chown user 1

no error, but owner is still root. This is very irritating I have 100s of such files to work with.

---------- Post updated at 04:36 PM ---------- Previous update was at 04:04 PM ----------

Thanks I got it sorted, problem was ownership on a mounted directory.
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
replace awk with a perl one liner (REGEXP and FS) bora99 Shell Programming and Scripting 5 02-10-2012 09:20 AM
perl : replace multiline text between two marker points rethink Shell Programming and Scripting 6 01-30-2012 05:04 AM
Search & Replace regex Perl one liner to AWK one liner verge Shell Programming and Scripting 9 07-07-2011 02:50 AM
awk multiple-line search and replace one-liner louisJ Shell Programming and Scripting 8 05-07-2011 10:12 PM
Replace/Remove not specific text in perl chriss_58 Shell Programming and Scripting 4 03-24-2011 08:01 AM



All times are GMT -4. The time now is 06:37 PM.