摘要:
file="class.cpp"name=${file%.*}ext=${file#*.}echo "name=$name, ext=$ext"Output:name=class, ext=cppif file="/proj/class.cpp", name will be "/proj/class".% - means to delete the matched pattern from right to left, it is non-greedy, %% is greedy;# - means to dele 阅读全文
摘要:
'\n' in the replace pattern in sed command doesn't work in Mac OS X.On Debian, we can get bellowing result:root# echo abc | sed 's/[^\n]/&\n/g'abcroot# But on Mac, it goes like this:user$ echo abc | sed 's/[^\n]/&\n/g'anbncnuser$Solution is to add \'$' bef 阅读全文