piece of code
Can anybody tell what this piece of code is doing?
DIR_NAME=`echo $1 | cut -d" " -f 9 | sed 's/"//g'` |
Depends what's in $1 (probably the first argument to the script).
|
Quote:
$ could be either of two cases (1)$1 is a filename (2) $1 is a string value |
Care to give an example of both?
It looks like it's parsing a particular part of that string/filename to remove quotes and then assigning it to a variable called DIR_NAME. |
It's also got a bug. Here's sample output:
Quote:
Here's an alternate solution: Quote:
|
>>>sed 's/"//g'
what this does more specifically ? |
come on!!
if you type "info sed" then you can discover that 'substitute [globally]' is one of the most frequently used sed commands. As example: you can use it to remove double quotes... |
Quote:
Examples: Here, abc is replaced by vikas. Code:
-sh-3.00$ echo "abc def" | sed 's/abc/vikas/g' Code:
-sh-3.00$ echo "abc def" | sed 's/abc//g' In the same way, double quotes are removed here. Code:
sed 's/"//g' To have more examples and clear picture of sed, see these http://www.tldp.org/LDP/abs/html/x21467.html http://www.grymoire.com/Unix/Sed.html http://www.pathogenomics.sfu.ca/brin...xcmds.html#sed http://www.alexandersandler.net/sed-the-missing-manual http://www.linuxhowtos.org/System/se...m?ref=news.rdf http://www.gnulamp.com/sed.html http://www.unixguide.net/unix/sedoneliner.shtml http://www.unix.com/shell-programmin...iable-sed.html |
So Volcano -
Have you fixed the bug? Do you understand the sed "/g" modifier? |
All times are GMT -5. The time now is 01:40 PM. |