using wildcards in this perl command


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting using wildcards in this perl command
# 1  
Old 07-17-2007
using wildcards in this perl command

Hi there,

is it possible to use wild cards in this statement

Code:
ssh $remote_server 'perl -pi -e "s,EXP_SERIAL_19b8be67=\"\",EXP_SERIAL_`hostid`=\"UNKNOWN\"," /var/myfile'

This command works fine but the bit in bold (the 8 character hostid) will not always be 19b8be67 so I was hoping I could use some sort of wildcard that indicates the 8 characters directly after EXP_SERIAL_

ie something like

Code:
ssh $remote_server 'perl -pi -e "s,EXP_SERIAL_$$$$$$$$=\"\",EXP_SERIAL_`hostid`=\"UNKNOWN\"," /var/myfile'


Does anybody know how I could achieve this?

Cheers
# 2  
Old 07-17-2007
ok so I found out that "?" matches to an individual character so i tried


Code:
ssh $remote_server 'perl -pi -e "s,EXP_SERIAL_????????=\"\",EXP_SERIAL_`hostid`=\"UNKNOWN\"," /var/myfile'

and I got the error

Code:
/EXP_SERIAL_????????/: nested *?+ in regexp at -e line 1.

maybe I cant use/nest a regex in here afterallSmilie
# 3  
Old 07-17-2007
ok so ive answered my own question

instead of
Code:
????????

is used
Code:
.*=

where = is the next character after the 8 hostid numbers
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Find command and use of wildcards

greetings, below is the find command i am using for some filesystem maintenance: find /data/Engine \( -type d -name .snapshot -prune -o -type d -wholename "/data/Engine/*/CAE" \ -prune -o -type d -wholename "/data/Engine/*/CAD" -prune -o -name ".*.case" \)\ -mtime +365 -print0 -fls... (5 Replies)
Discussion started by: crimso
5 Replies

2. Shell Programming and Scripting

Date with Wildcards in Command

I have the following script (parts from help on this forum, thanks y'all): #!/usr/bin/ksh date '+%m %d %Y' | { read MONTH DAY YEAR DAY=`expr "$DAY" - 1` case "$DAY" in 0) MONTH=`expr "$MONTH" - 1` case "$MONTH" in 0) ... (5 Replies)
Discussion started by: he204035
5 Replies

3. UNIX for Dummies Questions & Answers

Help with rm command with wildcards

Hello everyone. My first time posting here. I have a question that may seem very insignificant to some but is one that I've been trying to address for the past several days (haven't had any luck looking online). I'm trying to clean a directory by removing old files that we no longer need.... (2 Replies)
Discussion started by: galileo1
2 Replies

4. Shell Programming and Scripting

Perl - grep issue in filenames with wildcards

Hi I have 2 directories t1 and t2 with some files in it. I have to see whether the files present in t1 is also there in t2 or not. Currently, both the directories contain the same files as shown below: $ABC.TXT def.txt Now, when I run the below script, it tells def.txt is found,... (5 Replies)
Discussion started by: guruprasadpr
5 Replies

5. 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

6. UNIX for Advanced & Expert Users

Wildcards

These 2 websites do a GREAT job of explaining different types of wildcards. I learned about the categories of characters which I never knew about at all. GNU/Linux Command-Line Tools Guide - Wildcards GREP (1 Reply)
Discussion started by: cokedude
1 Replies

7. Shell Programming and Scripting

Perl, open multiple files with wildcards

I have a question regarding Perl scripting. If I want to say open files that all look like this and assign them to a filehandle and then assign the filehandle to a variable, how do I do this? The file names are strand1.fa.gz.tmp strand2.fa.gz.tmp strand3.fa.gz.tmp strand4.fa.gz.tmp ...... (6 Replies)
Discussion started by: japaneseguitars
6 Replies

8. 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

9. Shell Programming and Scripting

Perl script to search and extract using wildcards.

Good evening All, I have a perl script to pull out all occurrences of a files beginning with xx and ending in .p. I will then loop through all 1K files in a directory. I can grep for xx*.p files but it gives me the entire line. I wish to output to a single colum with only the hits found. ... (3 Replies)
Discussion started by: CammyD
3 Replies

10. 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
Login or Register to Ask a Question