The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
quoting question aegis Shell Programming and Scripting 2 01-08-2009 07:35 AM
*.pm globs without quoting, *.pl doesn't. tphyahoo Shell Programming and Scripting 2 06-02-2006 12:37 PM
Quoting of special characters vibhor_agarwali UNIX for Dummies Questions & Answers 1 01-30-2005 04:58 AM
quoting echo 'it's friday' yls177 UNIX for Dummies Questions & Answers 3 09-20-2002 12:09 AM
Wildcards and quoting Bab00shka UNIX for Dummies Questions & Answers 2 09-16-2002 11:16 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 02-11-2009
acheong87 acheong87 is offline
Registered User
  
 

Join Date: Jan 2009
Posts: 6
csh quoting enigma

(no, i can't switch shells, although i'd love to. yes, i have read http://www.grymoire.com/Unix/CshTop10.txt.)

i finally managed to get an alias working the way i want it to, but i don't understand how one part of it works (highlighted in red):
alias log ' \\ set x=`echo \!:1 | /bin/sed -e "s/\([^_]\)/\1*\{_,\}/g" -e "s|\(.*\)|$L/\1*|"`; \\ 80; ls -1hAFL $x; 80; set x=`echo $x | /bin/awk '\''{ print $1 }'\''`; \!:2* $x;'
Code:
alias log ' \\
    set x=`echo \!:1 | /bin/sed -e "s/\([^_]\)/\1*\{_,\}/g" -e "s|\(.*\)|$L/\1*|"`; \\
    80; ls -1hAFL $x; 80; set x=`echo $x | /bin/awk '\''{ print $1 }'\''`; \!:2* $x;'
        
-->
Code:
alias log ' \\
    set x=`echo \!:1 | /bin/sed -e "s/\([^_]\)/\1*\{_,\}/g" -e "s|\(.*\)|$L/\1*|"`; \\
    80; ls -1hAFL $x; 80; set x=`echo $x | /bin/awk '\''{ print $1 }'\''`; \!:2* $x;'
i've done plenty of googling, but i don't get it. what does the escaped single-quote even mean? is the outer-most single-quote (the entire alias expression) closed by the first red single-quote, or is the first red single-quote the start of another set of weirder quotes, or...
  #2 (permalink)  
Old 02-17-2009
otheus's Avatar
otheus otheus is offline Forum Staff  
Moderator ala Mode
  
 

Join Date: Feb 2007
Location: Innsbruck, Austria
Posts: 1,886
It's there to protect the `command` subexpression from being evaluated at the time the alias is created. You want this command to actually run when the alias is executed. The { print $1 } is a tiny awk script which must be quoted to prevent $1 from being evaluated by the shell at run-time.

By the way, you could avoid these funny quotes by using cut:
set x=`echo $x|cut -d " " -f 1`
Code:
set x=`echo $x|cut -d " " -f 1`
        
-->
Code:
set x=`echo $x|cut -d " " -f 1`
Closed Thread

Bookmarks

Tags
csh c shell alias quoting

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 07:42 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0