Penguin

Differences between version 55 and predecessor to the previous major change of BashNotes.

Other diffs: Previous Revision, Previous Author, or view the Annotated Edit History

Newer page: version 55 Last edited on Saturday, April 21, 2007 8:43:06 am by BenStaz Revert
Older page: version 52 Last edited on Friday, March 16, 2007 8:16:47 pm by LawrenceDoliveiro Revert
@@ -372,8 +372,11 @@
 !How can I see what my command will look like after bash expands it? 
  
 After typing the command, press ''Esc'' then press ''C-e'' 
  
+!Bash C-style for loop construct  
+  
+for ((i=1; i<100;i++));do echo $i; done;  
  
 !How can I do Division in bash using floating point numbers? 
  
 Use ''bc'' 
@@ -395,12 +398,34 @@
 if [ $bla -eq 1 -o $cars -eq 3 -o $monkeys -eq 4 ]; then 
  echo "Westside" 
 fi 
 </verbatim> 
+  
+!How can I supply filenames with a prefix of '-' '--' as arguments to a program?  
+  
+Say you have a file called '--test'.  
+If you wanted to use vim to edit this file then you would do:  
+  
+*vim -- --test  
+  
+The '--' tells the command that what follows is an argument, NOT to interpret them as options.  
+  
+!How to directly interpret a shell script by the current shell. (Without forking a subshell)  
+  
+*. <myscript>  
+  
+If the above script makes a change to the environment, it is the environment of this shell that is changed.  
+So if inside the script we change the directory, then when the script has finished being interpreted we will find ourselves in the new directory.  
+  
+Note : This can be handy when you want to reset the shell environment variables.  
+  
+Just do:  
+  
+*. ~~/.bashrc  
  
 !! See also 
  
 * CommonErrors, under "Your shell hangs" 
 * BashOneLiners 
 * SpacesInPathNames 
 * PortabilityNotes 
 * [bash reference manual|http://www.gnu.org/software/bash/manual/bashref.html]