<?xml version="1.0" encoding="utf-8" ?><?xml-stylesheet type="text/xsl" href="http://www.daniweb.com/js/rss.xsl"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/">
	<channel>
		<title>DaniWeb IT Discussion Community
			 - Shell Scripting			Solved Articles
					</title>
		<link>http://www.daniweb.com/software-development/shell-scripting/solved/_/113</link>
		<description>Our Shell Scripting forum is the place for Q&amp;A-style discussions related to *nix shell scripting languages such as bash. Note that we also have a separate Perl forum within the Software Development category.</description>
		<language>en-US</language>
		<ttl>60</ttl>
		<!-- PubSubHubbub Discovery -->
		<link rel="hub" href="http://daniweb.superfeedr.com/" xmlns="http://www.w3.org/2005/Atom" />
		<link rel="self" href="http://www.daniweb.com/rss/pull/113/solved" xmlns="http://www.w3.org/2005/Atom" />
		<!-- End Of PubSubHubbub Discovery -->
				<item>
			<title>awk sort data bourne shell</title>
			<link>http://www.daniweb.com/software-development/shell-scripting/threads/454720/awk-sort-data-bourne-shell</link>
			<pubDate>Thu, 16 May 2013 07:30:31 +0000</pubDate>
			<description>i have an awk script and in the end section i create my table data with printf and i want to sort it so i used pipe then sort i am calling it like this awk -f awkscript file in bash i can get it to work the way i ...</description>
			<content:encoded><![CDATA[ <p>i have an awk script and in the end section i create my table data with printf and i want to sort it so i used pipe then sort</p>

<p>i am calling it like this awk -f awkscript file</p>

<p>in bash i can get it to work the way i want using</p>

<pre><code class="language-sh">END{




for...



printf "%d\t%d\t%d\n",x, a[x],b[x] | "sort -t $'\t' -k3,3rn -k2,2rn"
</code></pre>

<p>but this does not work bourne shell on solaris.</p>

<p>as an experiment i did this</p>

<pre><code class="language-sh"> printf "%d\t%d\t%d\n",x, a[x],b[x] &gt; "testfile"
</code></pre>

<p>then on the shell i did this</p>

<pre><code class="language-sh">cat testfile | sort -t "`printf '\t'`" -k3,3nr -k2,2rn
</code></pre>

<p>and this works fine.</p>

<p>My issue is not sure how to insert that back into my awk script as i get confused with all the ""'` etc</p>

<pre><code class="language-sh">printf "%d\t%d\t%d\n",x, a[x],b[x] | "sort -t "`printf '\t'`" -k3,3nr -k2,2rn"
</code></pre>

<p>is error</p>

<p>ive tried different things but cant figure it out</p>

<p>cheers</p>
 ]]></content:encoded>
			<category domain="http://www.daniweb.com/software-development/shell-scripting/113">Shell Scripting</category>
			<dc:creator>mossman mudas</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/software-development/shell-scripting/threads/454720/awk-sort-data-bourne-shell</guid>
		</item>
				<item>
			<title>Using vi commands in Shell Script</title>
			<link>http://www.daniweb.com/software-development/shell-scripting/threads/453869/using-vi-commands-in-shell-script</link>
			<pubDate>Fri, 03 May 2013 20:46:42 +0000</pubDate>
			<description>vi is basically used independently .....but what if vi commands are used in shell script ? I am trying to accomplish functionality of mv command using a shell script. what I want is to yank whole text of one file1 and paste it in file2. this all should happen in ...</description>
			<content:encoded><![CDATA[ <p>vi is basically used independently .....but what if vi commands are used in shell script ?<br />
I am trying to accomplish functionality of mv command using a shell script.</p>

<p>what I want is to yank whole text of one file1 and paste it in file2.<br />
this all should happen in Shell Script.</p>

<p>So far I have dont following script.</p>

<pre><code class="language-sh">#!/bin/bash
#file.sh

echo -e "\n\t|------------------ File Transfer -----------------------|"

while [ "$ch" != "n" ]
do
        echo -e "\nEnter directory"
        read dir

        echo -e "\nEnter filename"
        read flnam

        if [ -d $dir ]
        then
                if [ -e $flnm ]
                then
                        vi $flnm `| "+y | esc | :x`     # ERROR
                        cd $dir                         
                        vi $flnm `| p | esc | :x`       # ERROR

                fi
        else
                echo "Directory does not exists."
        fi

        echo "Do you want to try again? (y/n)"
        read ch
done
</code></pre>

<p>vi commands are not working in shell script.....I know am missing right format of its use.<br />
Any Suggestions ?</p>
 ]]></content:encoded>
			<category domain="http://www.daniweb.com/software-development/shell-scripting/113">Shell Scripting</category>
			<dc:creator>Rahul47</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/software-development/shell-scripting/threads/453869/using-vi-commands-in-shell-script</guid>
		</item>
				<item>
			<title>is it possible to compare two files created on different platforms?</title>
			<link>http://www.daniweb.com/software-development/shell-scripting/threads/453071/is-it-possible-to-compare-two-files-created-on-different-platforms</link>
			<pubDate>Tue, 23 Apr 2013 03:53:41 +0000</pubDate>
			<description>i have 2 files, one file created on Windows and another was made on Ubuntu, i want to use this command: comm -12 file1 file2 how do i do that?</description>
			<content:encoded><![CDATA[ <p>i have 2 files,</p>

<p>one file created on Windows and another was made on Ubuntu,</p>

<p>i want to use this command:</p>

<pre><code class="language-sh">comm -12 file1 file2
</code></pre>

<p>how do i do that?</p>
 ]]></content:encoded>
			<category domain="http://www.daniweb.com/software-development/shell-scripting/113">Shell Scripting</category>
			<dc:creator>1a2p3a4c5h6e</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/software-development/shell-scripting/threads/453071/is-it-possible-to-compare-two-files-created-on-different-platforms</guid>
		</item>
				<item>
			<title>how do i get decimal from a string</title>
			<link>http://www.daniweb.com/software-development/shell-scripting/threads/453033/how-do-i-get-decimal-from-a-string</link>
			<pubDate>Mon, 22 Apr 2013 14:19:53 +0000</pubDate>
			<description>i got a string var=96.33% from 120 how do i get 96.33 from $var?</description>
			<content:encoded><![CDATA[ <p>i got a string</p>

<p>var=96.33% from 120</p>

<p>how do i get 96.33 from $var?</p>
 ]]></content:encoded>
			<category domain="http://www.daniweb.com/software-development/shell-scripting/113">Shell Scripting</category>
			<dc:creator>1a2p3a4c5h6e</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/software-development/shell-scripting/threads/453033/how-do-i-get-decimal-from-a-string</guid>
		</item>
				<item>
			<title>calculate disc space used by files owned</title>
			<link>http://www.daniweb.com/software-development/shell-scripting/threads/452921/calculate-disc-space-used-by-files-owned</link>
			<pubDate>Sat, 20 Apr 2013 15:55:34 +0000</pubDate>
			<description>i want to find the total space used for the files owned by me from my current directory. i have du -sh `find ./ -user $USER -type f` which gives 8.0K ./.a 8.0K ./t 4.0K ./cat/A 4.0K ./a using -s has no effect. using du -sh by itself includes the ...</description>
			<content:encoded><![CDATA[ <p>i want to find the total space used for the files owned by me from my current directory.</p>

<p>i have</p>

<pre><code class="language-sh">du -sh `find ./ -user $USER -type f`
</code></pre>

<p>which gives</p>

<pre><code class="language-sh">8.0K    ./.a
8.0K    ./t
4.0K    ./cat/A
4.0K    ./a
</code></pre>

<p>using -s has no effect.</p>

<p>using du -sh by itself includes the space for files not owned by me and also includes space used by folders themselves.</p>

<p>I want to be able to add all of the above and displayed in readable format automatically.</p>

<p>At this stage i am happy to include the space used for folders or not, doesnt matter.</p>

<p>Any tips would be appreciated.</p>
 ]]></content:encoded>
			<category domain="http://www.daniweb.com/software-development/shell-scripting/113">Shell Scripting</category>
			<dc:creator>mossman mudas</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/software-development/shell-scripting/threads/452921/calculate-disc-space-used-by-files-owned</guid>
		</item>
				<item>
			<title>awk</title>
			<link>http://www.daniweb.com/software-development/shell-scripting/threads/450791/awk</link>
			<pubDate>Sat, 23 Mar 2013 14:05:07 +0000</pubDate>
			<description>$ awk -F &quot;:&quot; 'NR!=1 {print $1}' test1.txt what does this mean?? especially &quot;:&quot;??</description>
			<content:encoded><![CDATA[ <p>$ awk -F ":" 'NR!=1 {print $1}' test1.txt<br />
what does this mean?? especially ":"??</p>
 ]]></content:encoded>
			<category domain="http://www.daniweb.com/software-development/shell-scripting/113">Shell Scripting</category>
			<dc:creator>pooh1234qwerty</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/software-development/shell-scripting/threads/450791/awk</guid>
		</item>
			</channel>
</rss>