I would like to convert a list containing bunch of svn URLs of issues:cat list.txt    //svn.server.address/repos/project/module1/branches/issue-001-name1    //svn.server.address/repos/project/module2/branches/issue-002-name2    //svn.server.address/repos/project/module3/branches/issue-003-name3    ...into newlist.txt that plus svn command and folder names to checkout them, like this:    svn co //svn.server.address/repos/project/module1/branches/issue-001-name1 issue-001-module1    svn co //svn.server.address/repos/project/module2/branches/issue-002-name2 issue-002-module2    svn co //svn.server.address/repos/project/module3/branches/issue-003-name3 issue-003-module3    ...I have tried something like:eval $(awk -F'/branches/' '{print $2}' list.txt|awk -F'-' '{print i=$1-$2}')eval $(awk -F'/branches/' '{print $1}' list.txt|awk -F'/' '{print j=$NF}')name=$i-$jawk '{print svn co $1 n}' n=$name list.txt >newlist.txtBut it would always get the last variable, I'm totally newbie for this so any help would be greatly appreciated!
How can awk cut certain fields and add to the end of each line?
awk
awk v1It seems you want to use the 3rd path element combined with last path element as the module to check out. In that case you can do it like this within awk:awk -F/ '{  split($NF, a, -)  module=a[1] - a[2] - $6  print svn co  $0   module}' list.txtExplanationsplit separates $NF at hyphens into the a array (e.g. a[1] = issue, a[2] = 001 and a[3] = name1). The first two elements of a are then concatenated  together with the 3rd path element ($6) to produce the desired module name.awk v2If your version of awk supports specifying the field separator as a regular expression, you can use this simpler alternative:awk -F'[/-]' '{ print svn co  $0   $8 - $9 - $6 }' list.txtsedA GNU sed alternative:sed -r 's:(([^/]*/){5})([^/]+)/([^/]+)/(([^-]+-){2})(.*):\1\3/\4/\5\7 \5\3:'Explanation(([^/]*/){5}) first five path elements, note // counts for two elements.([^/]+) the module bit.([^/]+) the branch bit.(([^-]+-){2}) first two hyphen delimited elements, e.g. issue-001-.Output in all casessvn co //svn.server.address/repos/project/module1/branches/issue-001-name1 issue-001-module1svn co //svn.server.address/repos/project/module2/branches/issue-002-name2 issue-002-module2svn co //svn.server.address/repos/project/module3/branches/issue-003-name3 issue-003-module3