Perl command error...


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Perl command error...
# 1  
Old 04-22-2010
Perl command error...

Good morning!

Imtrying to run:

Code:
#!/usr/bin/perl

perl -nle 'print if /\var\/log/' /etc/syslog.conf

But I keep getting error: Do you need to predeclare -nle.Im trying to create a script that read the contents of /etc/syslog.conf and print out every line that contains /var/log.

Last edited by pludi; 04-23-2010 at 01:55 AM..
# 2  
Old 04-22-2010
Quote:
Originally Posted by bigben1220
...

Imtrying to run:

[code]
#!/usr/bin/perl

perl -nle 'print if /\var\/log/' /etc/syslog.conf[code]But I keep getting error: Do you need to predeclare -nle.Im trying to create a script that read the contents of /etc/syslog.conf and print out every line that contains /var/log.
Run the Perl one-liner on the *nix command prompt.
My file "f4" is equivalent to your "/etc/syslog.conf" in the testcase below -

Code:
$ 
$ cat f4
first line
/var/log in this line
third line
and this line also has /var/log
fifth line
sixth line
and /var/log embedded in here too
$ 
$ perl -nle 'print if /\/var\/log/' f4
/var/log in this line
and this line also has /var/log
and /var/log embedded in here too
$

tyler_durden
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. AIX

Perl error : perl: warning: Setting locale failed.

This's my problem perl: warning: Setting locale failed. perl: warning: Please check that your locale settings: LC_ALL = "en_US.UTF-8", LC__FASTMSG = "true", LC_MESSAGES = "", LC_CTYPE = "en_US.UTF-8", LC_TYPE = "en_US.UTF-8", LANG = "EN_US"... (1 Reply)
Discussion started by: bobochacha29
1 Replies

2. Shell Programming and Scripting

Perl error in batch command but works one at a time

In the below perl executes if one file is processed perfect. However, when multiple files are processed in batch which is preferred I get the below error that I can not seem to fix it as the '' necessary for the command to execute, but seem to only work for one -arg option. Thank you :). ... (2 Replies)
Discussion started by: cmccabe
2 Replies

3. Shell Programming and Scripting

Perl command error

In the attached file I get this error. Thank you :). C:\cygwin\home\cmccabe\windows_annovar.sh: line 117: perl: command not found (17 Replies)
Discussion started by: cmccabe
17 Replies

4. Shell Programming and Scripting

perl/unix: script in command line works but not in perl

so in unix this command works works and shows me a list of directories find . -name \*.xls -exec dirname {} \; | sort -u | > list.txt but when i try running a perl script to run this command my $query = 'find . -name \*.xls -exec dirname {} \; | sort -u | > list.txt';... (2 Replies)
Discussion started by: kpddong
2 Replies

5. Shell Programming and Scripting

Perl & Sed command -- Out of Memory Error

Experts, We used to receive our source files with '~^' as row delimiter. This file contains 2500K records and two of the columns having value in HTML formats within the file. While running the below commands against the file, we are encountering out of memory, could you please help to... (3 Replies)
Discussion started by: srivijay81
3 Replies

6. Shell Programming and Scripting

Convert Sed command to perl command

Hello, Can any perl experts help me convert my sed string to perl. I am unsuccessful with this. I have to remove this string from html files OAS_AD('Top'); I have come up with this. However the requirement is in perl. for find in $(find . -type f -name "file1.html") ; do cat $find |... (2 Replies)
Discussion started by: abacus
2 Replies

7. Shell Programming and Scripting

combine two perl lines into a single perl command

Hi Everyone, i have a string 00:44:40 so: $tmp=~ s/://gi; $tmp=~s/({2})({2})({2})/$1*3600+$2*60+$3/e; the output is 2680. Any way to combine this two lines into a single line? Thanks (4 Replies)
Discussion started by: jimmy_y
4 Replies

8. Shell Programming and Scripting

Error executing shell command from a perl script

Hi Gurus, I've a find command that gets the list of files from a source directory where the extension is not html, xml, jsp, shtml or htaccess. The below find command runs fine from the command prompt or in a shell script. I need to eventually run it in a PERL script and am getting the... (5 Replies)
Discussion started by: voorkey
5 Replies

9. Shell Programming and Scripting

[Perl] Accessing array elements within a sed command in Perl script

I am trying to use a script to replace the header of each file, whose filename are stored within the array $test, using the sed command within a Perl script as follows: $count = 0; while ( $count < $#test ) { `sed -e 's/BIOGRF 321/BIOGRF 332/g' ${test} > 0`; `cat 0 >... (2 Replies)
Discussion started by: userix
2 Replies

10. Shell Programming and Scripting

Perl Script Error with find command

Guys, I need to find all the files ending with either dmp or dmp.Z. This command is giving me error. @files =`find $path \(-name "*.dmp" -o -name "*.dmp.Z"\) -mtime +30`; sh: 0403-057 Syntax error at line 1 : `(' is not expected. Thanks in advance (4 Replies)
Discussion started by: MKNENI
4 Replies
Login or Register to Ask a Question