Dr. Mark Humphrys

School of Computing. Dublin City University.

Home      Blog      Teaching      Research      Contact

My big idea: Ancient Brain

Search:

CA114      CA170

CA668      CA669      Projects


What is wrong with these Shell scripts?


  1.  
     
    # list files given in the argument:
    
    ls$1 
     
    
  2. 
    # find processes and kill them:
    # how do I know this script has never been run?
    
    for i in 'ps -f | grep textedit' 
    do 
     kill $i 
    done 
    
    
  3. 
    # what caused this do you think?
      
    Echo "some text" 
     
    Ls -al 
     
    
  4.  
    cd /
    cd ..
    
    
  5. 
    # list all files on disk, collect results in some output file:
    
    cd /
    ls -alR > outputfile.log
    
    
  6. 
    # substitute new text for old text in a number of files:
    
    read OLDTEXT
    read NEWTEXT
    
    for i in $* 
    do 
     sed -e "s|$OLDTEXT|$NEWTEXT|g" $i > $i 
    done 
    
    
  7.  
    # how do I know this script has never been run?
    
    find .   -name $1    > /dev/null 2> /dev /null
    
    
  8. 
    # how do I know this script has never been run?
    
    echo "enter old text" 
    read OLDTEXT 
     
    echo "enter new text 
    read NEWTEXT 
     
    


ancientbrain.com      w2mind.org      humphrysfamilytree.com

On the Internet since 1987.

Wikipedia: Sometimes I link to Wikipedia. I have written something In defence of Wikipedia. It is often a useful starting point but you cannot trust it. Linking to it is like linking to a Google search. A starting point, not a destination. I automatically highlight in red all links to Wikipedia and Google search and other possibly-unreliable user-generated content.