$ in sed under tcsh vs bash


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers $ in sed under tcsh vs bash
# 1  
Old 03-31-2009
' in sed under tcsh vs bash

In bash, I can match the ' character in a substition involving the line ending symbol $, easily.
In tcsh I ran into a problem.

Code:

sed "s/$/'/g" filename
sed "s/$/'/g" < filename
sed -e "s/$/'/g" filename

Unmatched '.

Where can I find out why this is the case?

Last edited by uiop44; 03-31-2009 at 07:27 PM..
# 2  
Old 03-31-2009
Try with escape character.

sed "s/$/\'/g" filename
sed "s/$/\'/g" < filename
sed -e "s/$/\'/g" filename
# 3  
Old 03-31-2009
EOL ($) simple regexp in tcsh vs bash

I found the answer (I think).

It is in the tcsh man page.

Code:

sed "s/$/blah/g" filename

If you use double quotes (") this won't work. The dollar sign ($) will be interpreted as a variable. You'll get "Illegal variable."

But if you use single quotes...

Code:

sed 's/$/blah/g'

This works.

Now how do you deal with substituting a single quote characater?

Code:

sed 's/$/\'/g' filename
sed "s/$/\'/g" filename

Neither works. (Using FreeBSD, console or xterm.)

I'm reading the tcsh man page now... hoping to find the answer.

Update: I read some writings on the internet. The grymoire site says mixed quoting is a problem. Seems like, based on other stuff I've read, csh/tcsh makes it difficult to use the many UNIX utilities (i.e. script them), but may make it easier to call C functions of the OS, from the command line?

And ksh was an attempt to blend the two uses of the shell: UNIX utilities and UNIX C functions? The later I suspect is a rarer use?

Last edited by uiop44; 04-03-2009 at 09:18 PM..
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Tcsh script - sed command for special characters

Hi, I am using sed command to replace following line in gz file- sed -n 's/""COS_12_TM_1" ( 1101110101001001010011110100000010110100010010000000100000000010XX010000000 )"/""COS_12_TM_1" ( 110111010100100101001111MM00000010110100010010000000100000000010XX010000000 )"/g' filename.gz $x=... (4 Replies)
Discussion started by: Preeti Chandra
4 Replies

2. Shell Programming and Scripting

Bash tcsh Script runs in terminal but not folder

So, I made a script beginning with #!/bin/bash on gedit. And I double clicked it to run in terminal and I end up with "The child process exited normally with status 127" and "command not found". If I run the same script from the terminal as "tcsh (script name)" it runs just fine. If I... (8 Replies)
Discussion started by: OntorEska
8 Replies

3. Debian

Using sed with bash variables

Hi Guys I have another problem I'm trying to solve and hope that some one can help me here. This is the scenario: I have a file and I want to add a line on the 3rd line of the file using a bash script. but instead its adding the the bash variable $WEBSITE. Below is the bash script I'm... (6 Replies)
Discussion started by: linuxjunkie
6 Replies

4. Shell Programming and Scripting

Bash and sed compatibility

Hi i am having a stange problem. Basically for my sed script used within bash i can unly use a single Quote with sed '. (if i use " then i get command garbled error with sed ) The problem with this is BASH does not interprit variables within single quote ' so we cannot use any of the BASH... (7 Replies)
Discussion started by: vash
7 Replies

5. Shell Programming and Scripting

Bash can't find file but tcsh can why?

I have a short script for compiling an old program. It's a simple text file 'ccprog' created in emacs. The permissions were changed with 'chmod 775 ccprog' to make it an executable. When I try to run ccprog I get "bash: ./ccprog: No such file or directory". If I change to tcsh ccprog runs. Why... (68 Replies)
Discussion started by: muddauber
68 Replies

6. Shell Programming and Scripting

Bash sed problem

Hi, I need to escape slashes in my text, so I use this line: search_string=`echo $var | sed 's@/@\\\/@g'`I expect that to replace a slash with a backslash followed by a slash. That works nicely, but it has a problematic side-effect. If there are two spaces in the var it replaces them with... (3 Replies)
Discussion started by: RickS
3 Replies

7. UNIX for Dummies Questions & Answers

An alternative to BASH/TCSH?

Greetings! I love the power and control offered by BASH but detest its syntax! Is there some alternative *nix shell language? (other than TCSH) Or maybe a wrapper that affords the use of BASH commands via an easier syntax? I considered creating a complicated system of aliases to... (8 Replies)
Discussion started by: Koalaboration
8 Replies

8. Shell Programming and Scripting

for / foreach syntax issues (in bash or tcsh)

So I am new to unix, and actually anything outside drag and drop with the mouse (been learning for about a week so far) . I have been using the foreach command in tcsh because I am working on a group of files. Basically what I need is to insert part of the filename as the first line in the file.... (0 Replies)
Discussion started by: thepolypore
0 Replies

9. Shell Programming and Scripting

using Sed in Solaris bash

I am trying to execute a script with sed that works well in ksh(Linux) however in bash(solaris 8) though it does not give any errors the output file becomes 0 byte. header of the script: ksh:2$ head news.ksh #!/bin/ksh... (2 Replies)
Discussion started by: acharania2011
2 Replies

10. Shell Programming and Scripting

BASH -- sed -- variable

Hi, I'm new at bash scripting -- can anyone here help me about the sed command? I need to be able to edit and or delete a text from an outside file ie file.txt -- I'm passing a variable and not a string I was thinking of something like echo -n "What do you want to edit?: " read edit sed... (1 Reply)
Discussion started by: Imajean
1 Replies
Login or Register to Ask a Question