Is there a way to set ' and " as a non quotes type in bash?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Is there a way to set ' and " as a non quotes type in bash?
# 1  
Old 05-16-2011
Is there a way to set ' and " as a non quotes type in bash?

Howdy, I got a script that adds a esc char before all chars interpeted by bash shell but I wan't other solution. Is there a way to set ' and " as a non quotes type in bash (some local variable)? Have found that scsh is a non-quoting type shell but after reading Why I don't use scsh as a scripting language anymore - Andreas Bernauer's personal blog I
don't wanna use it. Do you have some ideas for bash solution to this problem?

Thanks, Johny
# 2  
Old 05-16-2011
You can use 'tr' to swap them for other characters.
# 3  
Old 05-18-2011
Use a quoted here documents

Use a quoted here document. Make sure you quote your identifier or the quotes will still give you problems.

You can tell when you have done it right because you don't have to type Ctrl-D after you type the unquoted identifier at the end.

Code:
# cat input_file.csv
Jim's,,cat,,,flies
Jessie's,,dog,,,climbs
#sed -nf - input_file.csv <<-'TOHERE'
/Jim's/p
TOHERE
Jim's,,cat,,,flies

All this really does is create a sort of on the fly file on standard input.

Last edited by freegnu; 05-18-2011 at 09:22 PM.. Reason: Environment variables didn't expand. Removed that advice.
# 4  
Old 05-19-2011
Yes, << here data is written to a tmpfile() in /tmp/ that is opened as stdin and unlinked (to be deleted at close) after open. I always figured "echo '...'|" was cheaper, but you need to escape any embedded ' to '"'"' (single-double-single-double-single).
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash script - Print an ascii file using specific font "Latin Modern Mono 12" "regular" "9"

Hello. System : opensuse leap 42.3 I have a bash script that build a text file. I would like the last command doing : print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt where : print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies

2. Shell Programming and Scripting

Replacing double quotes with the unicodes "urgent!"

Hi, I have the following text in a file <div class="snippet abstract"> We present a new "model" for multiple-input-multiple-output (MIMO) 'outdoor' has many things "what" ever </div></a href=sdfkkf"> </div> <div class="snippet context"> I have to replace the string between the <div... (1 Reply)
Discussion started by: vms
1 Replies

3. Shell Programming and Scripting

Confusion with "su -c" and quotes, user context switching?

Trying to execute commands for different Unix user with that user's environment variable context without fully switching as that user using sudo && su capabilities. Hoping this would help with security and not having to waste time switching between 10 different app users on same server. I do... (6 Replies)
Discussion started by: kchinnam
6 Replies

4. Shell Programming and Scripting

Expect scripting - How to match a double quotes " "

I am trying to match a text which contains the " ", from the log file. But it doesn't match. I understand that " " has got a special meaning to TCL/Expect. hence I tried the following, but no luck. expect -ex { "lp -c -demail -ot\\\"firstname_surname@gmail.com\\\"... (3 Replies)
Discussion started by: prakasuj
3 Replies

5. HP-UX

How to set up "sudo su -" to root with no need to type password?

Tittle has it.... Thanks friends... (2 Replies)
Discussion started by: 300zxmuro
2 Replies

6. Shell Programming and Scripting

Creating a Shortcut (to just type "l" but it runs "ls -lah")

How do I create shortcuts? For example: I just want to type one key "l" and have it output the command of "ls -lah" I believe it's creating a file called l with 755 permissions but I'm not sure where to put the file. *if it matters, I'm on a shared hosting web server using cPanel with... (2 Replies)
Discussion started by: ijustsawmars
2 Replies

7. UNIX for Dummies Questions & Answers

No "set" command in bash

I am just starting out and learning from "Linux and Unix programming tool, A primer" - Sarwar, Al-Saqabi. In the first chapter I am required to run the command set then list the settings for the environment variables shown. When I run set, I get a list of actual code and methods, not a list of... (5 Replies)
Discussion started by: dunsta
5 Replies

8. Shell Programming and Scripting

Removal of comma(,) present inbetween double quotes(" ")

Hi Experts, I have a file with some of the records contain double quotes. If I found a double quote(") in any particular record , I need to look for the next double quote in that particular record and in between these quotes, if any comma(,) is there I need to replace with Tilde (~) in the same... (12 Replies)
Discussion started by: vsairam
12 Replies

9. Shell Programming and Scripting

comparing scalars contaning "DOUBLE QUOTES" as data

Hello to all, Does anyone know the solution ? Two strings A and B are present. I want to check whether B is a Substring of A. 1. The value of A is - 29 * * * /bin/ls "test" "tmp*" "log*" (Note: Pl note that A contains DOUBLEQUOTES, ASTERISK & FRONTSLASH) 2. The value of B is -... (5 Replies)
Discussion started by: rssrik
5 Replies

10. Programming

Differece between "env" and "set" command

Hi, Please clarify what is the difference between "env" and "set" command. I guess set will display the system variables and user defined variables. Thanks Sweta (1 Reply)
Discussion started by: sweta
1 Replies
Login or Register to Ask a Question