Learn Bash the Hard Way by Ian Miell

Learn Bash the Hard Way by Ian Miell

Author:Ian Miell
Language: eng
Format: mobi, epub, pdf
Publisher: leanpub.com
Published: 2017-12-31T16:00:00+00:00


these list of items:

Spaces in filename1.txt Spaces in filename2.txt

What we want to do is treat the spaces like any other character. We can do this by altering the IFS variable to remove the space and re-running the for loop:

16 $ IFS=$'
' 17 $ for f in $(ls) 18 > do 19 > ls $f 20 > done

This might sound obscure but it’s quite frequent in bash to perform operations over bunches of files like this:

$ find . -type f | xargs -n1 grep somestring

and in these cases you may have files lying around that have spaces in their names. Then your scripts can fail in ways that it can be difficult to debug when you don’t know about the IFS variable.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.