Ubuntu :: Correct Usage Of Perl Expression In 'rename'-shell Command

Jan 21, 2011

I want to rename some files in one directory and found the command 'rename' most appropriate.

Changing the file extension is easy since there are lot of examples for this.

But now I want to rename my files like this:

'somePrefix_blablabla.ext' --> '0_blablabla.ext'
'somePrefix_blablablablabla.ext' --> '0_blablablablabla.ext'

I DON'T want an incrementation, just the leading prefix '0_'

correct perl expression syntax for this?

View 2 Replies


ADVERTISEMENT

General :: Find Mechanism With Irregular Expression (find Command) Or Perl?

Sep 7, 2010

I have 4 Linux machines with cluster.My target is to find all kind of IP address (xxx.xxx.xxx.xxx) in every file in the linux system remark: need to scan each file in the linux system and verify if the file include IP address if yes need to print the IP as the following

more /etc/inet/file.example1

182.23.2.4
255.255.0.0
10.10.1.1

View 1 Replies View Related

Programming :: 32512 Error Code In Perl When Trying To Run Shell Command?

Nov 29, 2010

when I execute the command from the shell command line - it works and no error code.if I do the exact same command from a perl file - it fails with code 32512.the file is created from the same perl script that runs the command that fails. file permission is 0664.

Code:
#! /usr/local/pkg/perl-5.8.8/bin/perl
print "Content-type: text/html

[code]...

View 3 Replies View Related

Ubuntu :: Use PyRenamer To Identify And Rename Files With Reserved Characters In The File Name / Expression

Aug 2, 2011

I'd like to use pyRenamer to identify and rename files with reserved characters in the file name. The files came from windows where I'm guessing the characters didn't cause problems. For example, I want to replace the ? (question mark), ' (single quote), etc. I tried using the escape () character before the special character in the replace field on the substitutions tab, but for some reason I don't believe that method was identifying the special characters. What is the correct way to identify a special / reserved character within a file name and replace it?

View 1 Replies View Related

Programming :: Perl About System Command / Fails If The Standard Shell Is Dash And Not Bash?

Jun 30, 2011

I am trying to fix a perl script, and I really suck at perl. But I think this problem will be easy for people who know it.

The problem is, I have an old setup script someone wrote many years ago. It fails if the standard shell is dash and not bash. The only way I've gotten it to work is to point /bin/sh to bash. I looked thru the script and it uses "system" many places, and I think that's the problem.

I searched for it and found this link:url

My plan is to include this function:

Code:
sub system_bash {
my @args = ( "bash", "-c", shift );
system(@args);
}
Then I could simply change all calls to system into system_bash and it should work?

The parameter to the system calls is usually some variable. What if the parameter is a list already? Do I need to test for it somehow, and if it's a list, prepend "bash" and "-c" to the list? How do I do that?

In the script there are lots of places like this:

my $error = system($cmd);
if ($error) {
die/warn "some error message";
}

Shouldn't there be a return in the system_bash function?

View 8 Replies View Related

Programming :: Perl Regular Expression To Change Character

May 26, 2009

Part of a perl script I am writing need to change the character at an index to upper case. Now i am new to perl and i am having some trouble getting it to do it. In c++ i would do something like

Code:

Now from what i understand the same thing is possible in perl using regular expressions. But i cant get it to work.

View 2 Replies View Related

Programming :: Bash - Syntax For ((<arithmetic Expression>)) Usage ?

Mar 18, 2010

I do not understand bash' syntax regarding the use of ((<arithmetic expression>)). $((<arithmetic expression>)) is tokenised to a single word. OK.

Code:

In isolation

Code:

It may not be used where a word is expected. This generates a syntax error. Why?

Code:

View 6 Replies View Related

Programming :: Perl Scripting: Search For Regular Expression Not Work?

Oct 13, 2010

I'm writing a Perl script to find an old key in a file and replace it with a new codefirst the program should find the old key in the input file. here is the way I used in my script. but it doesn't work.May you please let me know what is wrong and how I can correct it?the key is stored in the file in the following format:

PHP Code:
Key=("1234567" , someOtherVrable) 
I want 1234567

[code]...

View 1 Replies View Related

Programming :: Create Regular Expression In Perl To Remove All Delimiters (|) From File?

May 12, 2010

I am trying to create a regular expression in perl to remove all the delimiters (|) from a file. I was also thinking might I be able to use tr?

View 11 Replies View Related

Programming :: What Does The Following Shell Script Expression Mean

Nov 30, 2010

I've found the following script to copy files specified by a find output into a target directory.Code:find $SOURCE -name "*.avi" | xargs -i cp -v {} $TARGETWhat exactly does the colored expression mean? Does it refer to an array?

View 3 Replies View Related

Ubuntu :: Keyboard Shortcut To Search Through Past Shell Commands With Regular Expression?

Jul 14, 2010

Note: I have made a thread similar to this before, but the title/contents were too botched to repair.I know that using C-r you can search for past bash commands containing a particular string, but how would you search for past bash commands matching a particular regular expressionIs there a keyboard shortcut for that or do you have to use a shell command?

View 4 Replies View Related

General :: Memory Usage In Top Is Not Correct?

Apr 15, 2011

I am a bit worried about my linux vserver box. No more memory is left. To investigate this issue, i was looking at "top". But it deeply confuses me. It seems that no more memory is left, altough the process list in top never adds up to 100%

[Code]...

View 4 Replies View Related

General :: Correct Usage Of Grep To Search A Disk?

Mar 26, 2009

I've been trying to identify all files on my cut-down version of Damn Small which contain the text string "User Agent:" in them. Because it's only 120Mb in its entirety, I'm quite happy to have grep search the whole system. I'm using this command, but it just generates errors as you can see:

[root@localhost ~]# grep -R 'User Agent:' /*
grep: /dev/dri/card0: Invalid argument
grep: /dev/fuse: Operation not permitted

[code]....

View 13 Replies View Related

Ubuntu Installation :: Console Command To Remove All <expression>

Feb 11, 2010

My console fu is a bit lacking, as it seems that I can't figure out how to uninstall all packages containing a certain expression.

I tried: apt-get remove *expression*

View 1 Replies View Related

Ubuntu :: Mapping HAL's .fdi Expression To Xorg Expression?

Oct 6, 2010

I want to translate this .fdi clause

Quote:

<match key="info.product" string="PS/2 Generic Mouse">
<merge key="input.x11_options.EmulateWheel" type="string">true</merge>
<merge key="input.x11_options.EmulateWheelButton" type="string">2</merge>[code].....

into its Xorg equivalent. What does it look like?

View 1 Replies View Related

General :: Embed Command Output In Sed Expression?

Feb 20, 2010

sed -i 's/EXTRAVERSION =/EXTRAVERSION = -$(date +%D)/g' file would search in the file, file for the string: 'EXTRAVERSION =', and change every instance it finds to 'EXTRAVERSION = -02/20/2010'. BUT IT DOESN'T.It changes it to 'EXTRAVERSION = $(date +%D)', literally. I've tried single and double quotes in almost every possible configuration. Is there any way to tell sed that one desires the command output, not the literal text?

View 7 Replies View Related

General :: Sed: -e Expression #1, Char 27: Unterminated `s' Command

Feb 3, 2011

I am trying the execute the following

#!/usr/bin/python
import os
os.system("sed -e 's#^(.*) (.*)0http://12#' t2.txt > t3.txt")
os.system("cat t3.txt | sort | uniq -c | sort -rn | head > t4.txt")

But I receive the following error message.

sed: -e expression #1, char 27: unterminated `s' command

View 1 Replies View Related

General :: Bash - Rename Files With Spaces Using System Shell?

Jun 8, 2011

I named a number of files with spaces in them, and I want to replace the space with "_". However, every time I write a command in the shell with the file name (eg "Spring 2011"), the shell doesn't recognize the file or directory. What can I do about this? Is there any way to use the unicode character for a space?

View 5 Replies View Related

Programming :: Shell Script To Rename All Patern Mateched Directories And Files?

Jul 11, 2011

I have one directory with 3 level sub-directories, and about houndard files under those directories. I need a shell script to rename all patern mateched directories and files.

For example: the patern is AA in the directory or file name.

View 14 Replies View Related

Ubuntu :: Correct Syntax For Regex In Shell Script?

Nov 5, 2010

This command works to find files that have been updated in past 90 minutes:

Code:
find ( ! -regex '.*/..*' ) -type f -mmin -90
What changes need to be made to set this as an alias in, say, .cshrc file? I'm getting:

[code]....

View 5 Replies View Related

Networking :: Run Shell Script From Perl?

Sep 4, 2010

i want to run/call shell script from perl, i used this system( "sh", "script.sh", "--help" );The 'script.sh' contains IPTables firewall script, but that's not run.i test 'script.sh' with a simple thing such create a chain only, but it not doing.How to run a shell script from a Perl program?

View 4 Replies View Related

Server :: Running A Shell Script With Perl?

Jun 27, 2009

quick guidance on running a bash script using Perl. The script is calledarchive_web.sh.The regular script I have and use now (archive.sh) creates an archive directory (uses the current date as the dir name) and moves all existing files there.The script is cronned to run every day before midnight. I'd like to be able to run this "archiving script"manually, from the web, at my own discretion, rather than necessarily wait till midnight (but want it to run then, too, in case any new files present themselves in the directory).These shell scripts sit in an .htaccessed directory. Talk about making up verbs all over the place.

View 1 Replies View Related

Programming :: Call Shell Script In Perl Pm

Sep 4, 2010

i used ldap for authentication.now i have a perl script that users use it for login(contact.pl),then this script calls a shell script(ip.sh) for create iptables chain.

when i call that into contact.pl ,it just prints: usr/sbin/iptables but ip chains didn't change.what is problem? whenever run ip.sh in bash it works correctly

View 10 Replies View Related

Ubuntu :: Using The Rename Command With Ascending Numbers ?

Mar 14, 2011

In a moment of madness I decided to reorganise my mp3 player. I am putting everything into one folder (called 'all'), but first I am renaming the files to the following format:

artist ## songtitle

where ## is a number like 01, 02. This has been pretty straightforward with the songs that already started with a number, because then I could just

rename 's/(dd)/artist $1/' *.mp3

but I have a problem with those tracks that don't already have the track-numbers at the beginning. I suppose what I am asking is: can I turn

All Along the Watchtower.mp3
Purple Haze.mp3
Hey Joe.mp3

into

01 All Along the Watchtower.mp3
02 Purple Haze.mp3
03 Hey Joe.mp3

View 1 Replies View Related

General :: Shell Script Variable Usage ?

Feb 9, 2010

Having real problem with below:

If I do:

I get the result I want (a file in format of <name><yyyy>-<mm>-<dd>.zip cut down to just yymmdd); but not if I try to set it as a variable ...

View 2 Replies View Related

Software :: Automated Download Problem - Shell Ftp Vs Perl

Jun 1, 2009

I recently set up an automated shell script (bash on Ubuntu 8.10) to download new files from a server using ftp. Unfortunately the other end of the link is not terribly stable (and there is nothing I can do about this) which has resulted in the script hanging sometimes and then being kicked off again at the time set in the crontab.

This has resulted in multiple hung sessions taking up all the system resources.

The offending section of code is given below.

Code:

I'd like to know if there is a way I can force an exit if the connection hangs or alternatively if something like the Perl Net::FTP can handle these sorts of errors internally.

View 3 Replies View Related

Programming :: Compare Two Files Using Perl Or Shell Scripting?

Mar 8, 2010

I want to compare the following two tab-delimited .txt files (both were subsets of the original files) by comparing Columns 3 and 4 simultaneously. It is easy to compare C3 because both C3s are just numbers. But how to compare C4s?Basically, in File1, "G,G" = G in File2, "C,C" = C in File2, "A,A" = A in File2, "T,T"= T in File2.In File2, A/T in Column4 just equals "A,T" or "T,A" in Column4 of File1. C/T in Column4 just equals "C,T" or "T,C" in Column4 of File1, and etc.

File1:

C1C2 C3C4
ih509rs12345467244750"G,G"
ih499rs6049687244911"C,C"
ih508- 7244977"A,A"

[code]....

View 2 Replies View Related

General :: Ssh Command To Rename Files?

Dec 22, 2009

What is the ssh commands to rename a group of files?

I need to rename:
avatar_01.jpg
avatar_02.jpg

[code]....

View 5 Replies View Related

Ubuntu :: Command / Script To Rename Files In Datetime Order?

Jun 1, 2010

I'm trying to rename all files in a folder as such:

1.jpg
2.jpg
3.jpg

Renaming them is no problem, the problem I have is, they need to be in order of the datetime that they were taken, so that the 1.jpg would be the oldest file there. The difference in filetimes is going to be very small, around 3 or 4 tenths of a second.

The reason I need to do this is that I have another script (not quite finished yet), that takes the next three files in a loop and applies qtpfsgui to them to output an HDR image to another folder, then move on to 4,5 & 6, and: repeat.

View 9 Replies View Related

OpenSUSE :: What's The Zypper Command To Rename A Repository Name

Oct 16, 2010

What's the zypper command to rename a repository name? Not yast.

View 6 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved