Bash one liner to CSH


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Bash one liner to CSH
# 1  
Old 05-07-2009
Bash one liner to CSH

Hello all, I have a Bash command I'm using on one system that replaces text in filenames, I'ts not working on another system that uses the Csh shell. Can anyone tell me what I need to do

when i run

for f in *;do mv $f ${f/text1/text2};done


on the CSH shell i get ""Missing }.""
# 2  
Old 05-07-2009
Is bash shell present on the system? if yes add the shebang on first line
of your script
#!bin/bash
# 3  
Old 05-07-2009
ahh, no i forgot to mention, I would have just switched to bash, but its not installed, and I cannot install it.
# 4  
Old 05-07-2009
anyone?, cant find much help online about csh syntax
# 5  
Old 05-08-2009
Does anyone instead know of an equivalent command using CSH syntax, I am trying to replace the text in a few hundred filenames
# 6  
Old 05-08-2009
Well, since nobody seems to know the answer to this, I came up with an answer using a few lines of python, where are the Csh gurus? Anyway, here it is if it helps anyone, searches and replaces text in filenames in the current directory

import string
import os
for f in os.listdir('.'):
filename = f
filename = filename.replace("jonah","aaron")
os.rename(f,filename)
# 7  
Old 05-08-2009
Google for "csh programming considered harmful" (or just click here) to find CSH experts
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Awk/bash one liner replacement for a if condition

Hi. I wrote this small bash script, i want to compare second column from file1 with file2 if a pattern matches. Files are small and I am sure that pattern occurs only once. I think this can be rewritten into a awk one liner. Appreciate if someone could give me idea. Whole NR FNR confuse me :o ... (6 Replies)
Discussion started by: ctrld
6 Replies

2. UNIX for Beginners Questions & Answers

Perl one liner in bash script not replacing hours and minutes [HH:MM]

Hi I want to replace time stamp in the following line PROCNAME.Merge.exchMon.CODE.T_QSTART 08:45 read assuming the new time stamp is 09:45 ; the line is getting replaced as below :45 read I'm trying to use the perl one liner in bash script perl -pi... (4 Replies)
Discussion started by: charlie87
4 Replies

3. Shell Programming and Scripting

Need a script to convert csh to bash

Hi, Can anyone give me a script to convert csh to bash? or any key points which can help me to do so as i am new to it. (3 Replies)
Discussion started by: vineet.dhingra
3 Replies

4. Shell Programming and Scripting

Search & Replace regex Perl one liner to AWK one liner

Thanks for giving your time and effort to answer questions and helping newbies like me understand awk. I have a huge file, millions of lines, so perl takes quite a bit of time, I'd like to convert these perl one liners to awk. Basically I'd like all lines with ISA sandwiched between... (9 Replies)
Discussion started by: verge
9 Replies

5. Shell Programming and Scripting

Importing env from csh to bash

Hi All, In my account with csh shell, there are lots of env variables set and I want to import those all to bash in one stroke, is there any way to do it ? Thanks, D (1 Reply)
Discussion started by: Deei
1 Replies

6. UNIX for Dummies Questions & Answers

Running CSh scripts in Bash

Hi, I have some csh scripts and I want to run them in .bashrc. I use these techniques without any success: . test.csh or csh test.csh The first one assumed that the scripts is a bash script, so showed me errors. The second one finished without giving proper result. Can anybody offer... (6 Replies)
Discussion started by: mjdousti
6 Replies

7. Shell Programming and Scripting

Variable value inconsistency on BASH and CSH

May God never give you the bane of working on Solaris. Now, I am trying to run this simple shell script: #!/bin/sh input="a b c" data="123" while read eachline do data="$data$eachline" done << EOF $(echo "$input") EOF... (2 Replies)
Discussion started by: pavanlimo
2 Replies

8. Shell Programming and Scripting

how to make your bash script run on a machine with csh and bash

hi, i have a script that runs on bash and would like to run it on a machine that has csh and bash. the default setting on that machine is csh. i dont want to change my code to run it with a csh shell. is there any way i can run the script (written in bash) on this machine? in other words is there... (3 Replies)
Discussion started by: npatwardhan
3 Replies

9. Shell Programming and Scripting

different shell csh bash

I'm always having to work in the cshell, but occasionally want to run a command using bash. is that possible? I know I could write a shell script and call bash at the begining with #!/usr/bin/bash and then my command, is there another way? (1 Reply)
Discussion started by: ajp7701
1 Replies

10. Shell Programming and Scripting

From bash to csh and zsh

... Am I glad to find this forum (and vBulletin too, nice!).. OK, here's my issue. I have been handballed a bash script, not pretty but functional. I need to change to csh and zsh. For the csh I have the basics (e.g., such as change if/fi to if/endif, quote the variables, and bracket commands).... (10 Replies)
Discussion started by: lev_lafayette
10 Replies
Login or Register to Ask a Question