Thursday, November 5, 2009

awk vs sed

"Doing even seemingly simple thing in sed can quickly result in large,
difficult expressions, making most usage of sed hard to understand. sed
works well for simple cases of string filtering, but awk can often be a
more maintainable choice."



http://www.osnews.com/story/21004/Awk_and_Sed_One-Liners_Explained
seq 19 | tr '\n' ,
tr translate \n with ,



http://reallylongword.org/sedawk/
"&" stands for the matched part of the text

sed 's!.*/!!'

[jwang@osnet1 bin ]$ echo "/users/abc/bla1.exe" |sed 's!.*/!!'

bla1.exe


Remove MSDOS carriage return characters of each line.
sed 's/\r$//'




#!/bin/bash

while read line
do
# path=${line%%/*}
path=${line%/*}
echo $path
done < $1 > outfile

exit 0


#newusers/defgh/ik/albg2.exe
#->
#newusers/defgh/ik


#if %% result is :
#newusers

No comments:

Post a Comment