huangyingw
February 1st, 2010, 03:20 PM
Hello,
I had following script, named back.sh, as bellow:
#! /bin/bash
lv_file=/root/myproject/git/linux/shell/fundamental/log.txt
lvdisplay | grep -o "/dev.*" > $lv_file
cat $lv_file | while read file ; do
echo "$file" | sed 's/dev/media/' | mkdir -p '{}'
#echo "$file" | sed 's/dev/media/'
#mkdir -p 'echo "$file" | sed 's/dev/media/''
done
I would like the "mkdir -p" command to use the output of "echo "$file" | sed 's/dev/media/'", but it does not work.
BTW, another question:
How to use sed to replace directly from a string, instead of a file.
For example, I know
sed 's/dev/media/' < $file, in which file contains the string I would like to replace.
While, I am expecting a direct form like bellow:
sed 's/dev/media/' $mystring. But I don't know how to realize this.
I had following script, named back.sh, as bellow:
#! /bin/bash
lv_file=/root/myproject/git/linux/shell/fundamental/log.txt
lvdisplay | grep -o "/dev.*" > $lv_file
cat $lv_file | while read file ; do
echo "$file" | sed 's/dev/media/' | mkdir -p '{}'
#echo "$file" | sed 's/dev/media/'
#mkdir -p 'echo "$file" | sed 's/dev/media/''
done
I would like the "mkdir -p" command to use the output of "echo "$file" | sed 's/dev/media/'", but it does not work.
BTW, another question:
How to use sed to replace directly from a string, instead of a file.
For example, I know
sed 's/dev/media/' < $file, in which file contains the string I would like to replace.
While, I am expecting a direct form like bellow:
sed 's/dev/media/' $mystring. But I don't know how to realize this.