perl in tcsh


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting perl in tcsh
# 1  
Old 08-16-2012
perl in tcsh

hi,
I am completely new for tcsh scripting. Trying to write a code, need to implement following function there,
Code:
  perl -pi.bak -e 's/filei/file(i+1)/g' data

I want the "i" to increment and this should change the file name as
Code:
i = 1; file1->file2
i=2; file2->file3
and so on

also please let me know how can I introduce "PAUSE" or sleep in tsch based script.

Thanks,
# 2  
Old 08-16-2012
This will increment the digit following 'file':
Code:
perl -i.bak -pe 's/(file)(\d{1,})/$1 . (1 + $2/ge' data


This should give you a pause until you hit enter:
Code:
set thisvar = $<

# 3  
Old 08-17-2012
Hi
Its not working,Smilie here is the error :
Code:
perl -i.bak -pe 's/(file)(\d{1,})/$1 . (1 + $2/ge' card
syntax error at -e line 1, near "$2 }"
Execution of -e aborted due to compilation errors.

---------- Post updated at 12:56 AM ---------- Previous update was at 12:30 AM ----------

hi, it ran like this Smilie
Code:
perl -i.bak -pe 's/(file)(\d{1,})/$1 . (1 + $2)/ge'

could you please explain this command line?

thanks,

---------- Post updated at 01:11 AM ---------- Previous update was at 12:56 AM ----------

This should give you a pause until you hit enter:
Code:
set thisvar = $<

[/QUOTE]

Please let me know if I can set this pause as default to be some minutes.

Thanks
Pooja
# 4  
Old 08-17-2012
Code:
> perl --help
Usage: perl [switches] [--] [programfile] [arguments]
  -0[octal]       specify record separator (\0, if no argument)
  -a              autosplit mode with -n or -p (splits $_ into @F)
  -C[number/list]enables the listed Unicode features
  -c              check syntax only (runs BEGIN and CHECK blocks)
  -d[:debugger]   run program under debugger
  -D[number/list]set debugging flags (argument is a bit mask or alphabets)
  -e program      one line of program (several -e's allowed, omit programfile)
  -F/pattern/     split() pattern for -a switch (//'s are optional)
  -i[extension]   edit <> files in place (makes backup if extension supplied)
  -Idirectory     specify @INC/#include directory (several -I's allowed)
  -l[octal]       enable line ending processing, specifies line terminator
  -[mM][-]module  execute `use/no module...' before executing program
  -n              assume 'while (<>) { ... }' loop around program
  -p              assume loop like -n but print line also, like sed
  -P              run program through C preprocessor before compilation
  -s              enable rudimentary parsing for switches after programfile
  -S              look for programfile using PATH environment variable
  -t              enable tainting warnings
  -T              enable tainting checks
  -u              dump core after parsing program
  -U              allow unsafe operations
  -v              print version, subversion (includes VERY IMPORTANT perl info)
  -V[:variable]   print configuration summary (or a single Config.pm variable)
  -w              enable many useful warnings (RECOMMENDED)
  -W              enable all warnings
  -x[directory]   strip off text before #!perl line and perhaps cd to directory
  -X              disable all warnings



Code:
sleep s # Where 's' is seconds to sleep



hth
# 5  
Old 08-17-2012
Thanks, it worked...Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Tcsh Problems with # and []

Hallo, I try to write a program which processes an input-file linewise. I created the following minimal example: hash-problem:#!/bin/tcsh foreach text ("`cat $1`") echo $text endUsually, it works as expected, but there are two problems: 1. If the argument of hash-problem has an... (3 Replies)
Discussion started by: DanielDD
3 Replies

2. Shell Programming and Scripting

Tcsh to sh

Dear all, I have piece of command from tcsh, which I would like to be in my .bashrc file. However, I am comletely blank about the tcsh commandline. if (-e ~/forum/dir/code.sh) then source ~/forum/dir/code.sh endif Any piece of suggestions how to convert it to sh way? Thank you emily (5 Replies)
Discussion started by: emily
5 Replies

3. Shell Programming and Scripting

Help in tcsh script

Hi All, I wrote a tcsh script, but being a beginner it took me lots of efforts and on top of that I am still struggling with little modifications here and there. kindly have a loop. Line1 : I want it to run maximum of "Max" Which I am providing outside loop. So how the "for" should be... (10 Replies)
Discussion started by: nrjrasaxena
10 Replies

4. Shell Programming and Scripting

tcsh help

Does anyone no way my .tcsh_history file is filling up with a bunch of crap?? It is filled with lines like: ! ls eccracrascratcd ! ls mecd /hchoo "cratch2/mecd /sch2/mecd /sh2/mecd /scratchcd /scratch2/mecd /scratcraecd /ls mo "ls" > ! ls eccratch2/mecd /sc/ls"d /scratch2/mecd histecho "ls" o... (2 Replies)
Discussion started by: Bic121
2 Replies

5. Shell Programming and Scripting

logging out in tcsh

Hi! I want to log out of the tcsh shell without updating the history? Thanks, Jack. (3 Replies)
Discussion started by: jacki
3 Replies

6. UNIX for Dummies Questions & Answers

tcsh issues

HI, I am having strange issues with my tcsh shell. First, the "ln" command doesnt seem to work properly. I have a file "target" that is pointing to "file1". I cannot access file1 but that shouldnt matter. when I do this, ln -sf file2 target I get permission denied that I cannot access the... (1 Reply)
Discussion started by: sardare
1 Replies

7. UNIX for Dummies Questions & Answers

About tcsh shell

Hello, Why tcsh shell is not recommended ? then which one is better ? Also can you please let me know how to change own shell and config file? (3 Replies)
Discussion started by: darshakraut
3 Replies

8. UNIX for Dummies Questions & Answers

help in tcsh

am working in tcsh while writing a script, what is diff between foll two starting line #!/bin/csh #!/bin/csh -f Also can I use the same line for script in tcsh or I have to necessarily use #!/bin/tcsh I guess even #!/bin/sh will also do. Kindly clarify (3 Replies)
Discussion started by: mahendrakamath
3 Replies

9. Shell Programming and Scripting

how to call a perl script from tcsh?

Hi I am not sure how to call a perl script from a tcsh shell. do i need to set any environment variables? your help is appreciated Thanks (1 Reply)
Discussion started by: megastar
1 Replies

10. Shell Programming and Scripting

tcsh

I'm working on OpenOffice Localization; In that I need to work most of in 'tcsh' Since I have almost work till now in 'bash', I want to explore 'tcsh' much more .. An body suggest me a way ? books ? Thanks, :) (1 Reply)
Discussion started by: kartik
1 Replies
Login or Register to Ask a Question