cs2044_Lecture5

cs2044_Lecture5 - CS2044 Advanced Unix Tools Spring 2010...

Info icon This preview shows pages 1–11. Sign up to view the full content.

View Full Document Right Arrow Icon
CS2044 - Advanced Unix Tools Spring 2010 Lecture 5 David Slater dms236 at cornell.edu March 3, 2010 David Slater dms236 at cornell.edu CS2044 - Advanced Unix Tools
Image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Organization Homework is due on Friday at 6 pm. Questions about homework????????...? David Slater dms236 at cornell.edu CS2044 - Advanced Unix Tools
Image of page 2
Some Review What does this print? echo $ { PWD##*/ } David Slater dms236 at cornell.edu CS2044 - Advanced Unix Tools
Image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Some Review What does this print? echo $ { PWD##*/ } The name of the current directory (not the path) What if we do: x=2 y=’x’ echo $ { !y } David Slater dms236 at cornell.edu CS2044 - Advanced Unix Tools
Image of page 4
Some Review What does this print? echo $ { PWD##*/ } The name of the current directory (not the path) What if we do: x=2 y=’x’ echo $ { !y } This wil print 2. David Slater dms236 at cornell.edu CS2044 - Advanced Unix Tools
Image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
More Review Here is a script: #! /bin/bash # scriptname: something.sh for i in $(seq 1 $#) do echo $ { !i } done If I run it with ./something.sh abc def ghi klm what does it print? David Slater dms236 at cornell.edu CS2044 - Advanced Unix Tools
Image of page 6
More Review Here is a script: #! /bin/bash # scriptname: something.sh for i in $(seq 1 $#) do echo $ { !i } done If I run it with ./something.sh abc def ghi klm what does it print? It will print abc def ghi klm each on its own line. As written this is equivalent to for i in $ , but this way would allow us to loop over only some of the input parameters. David Slater dms236 at cornell.edu CS2044 - Advanced Unix Tools
Image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Random Bash Thing Of The Day xargs xargs constructs an argument list for an arbitrary unix command using stdin and executes the command For example find . -name "*.tmp" | rm rm: missing operand Try ‘rm -- help’ for more information. but find . -name "*.tmp" | xargs -t rm " rm ./temp.tmp -t flag has it print each command as it is executed. David Slater dms236 at cornell.edu CS2044 - Advanced Unix Tools
Image of page 8
More Or more realistically find . -name "*.tex" | xargs grep string and ls | xargs -t -I {} mv {} {}.old The second of which renames all files in the current directory with the .old suffex xargs is very useful. remember it takes stdout and converts it to a list of strings seperated by a space. David Slater dms236 at cornell.edu CS2044 - Advanced Unix Tools
Image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Do you grok gawk? gawk gawk is a small pattern matching programing language. The basic structure of an gawk program is pattern1 { commands } pattern2 { commands } . . .
Image of page 10
Image of page 11
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern