Questions Tagged With cuthttp://linuxexchange.org/tags/cut/?type=rssquestions tagged <span class="tag">cut</span>enMon, 20 Sep 2010 01:28:12 -0400Scripting question regarding cut and/or awkhttp://linuxexchange.org/questions/1359/scripting-question-regarding-cut-andor-awk<p>I'm running into a slight quandary with this particular script I need. I have a used egrep to yank from a large number of config files the location parameter of various unity databases. I have that information in a script. For example, the data looks like:</p> <pre><code>/home/test/demo/new /home/test/demo/old /home/yikes/mydir/ss/new /home/yikes/mydir/ss/old </code></pre> <p>So, the problem is each location doesn't have a particular field I can cut with "/" as the delimiter, however, the second to last field in that string is what I want: demo and ss. Is there an easy way to script this. I want to basically spin through this flat file (290 lines), in a new file print out the complete path and then on the same line separated by a space the second to last field.</p> <p>The end result would look like:</p> <pre><code>/home/test/demo/new demo /home/test/demo/old demo /home/yikes/mydir/ss/new ss /home/yikes/mydir/ss/old ss </code></pre> <p>Thanks for the help!</p>AndyMon, 20 Sep 2010 01:28:12 -0400http://linuxexchange.org/questions/1359/scripting-question-regarding-cut-andor-awkshell-scriptawkcut