Forum: Shell Scripting 12 Days Ago |
| Replies: 4 Views: 315 stat might give you what you want. |
Forum: Shell Scripting 19 Days Ago |
| Replies: 14 Views: 847 If you want to continue using awk as the workhorse, then:
ls -l f3.sh | awk '{ if( NF > 7 ) { split($7, a, ":"); print a[1] } }' |
Forum: Shell Scripting 20 Days Ago |
| Replies: 14 Views: 847 As you have been shown you can pipe the ls command to another program that further parses the output, in this case awk.
awk can do a lot of things, but even in its simplest form it can be very... |
Forum: Shell Scripting 21 Days Ago |
| Replies: 14 Views: 847 Look into the command touch |
Forum: Shell Scripting 21 Days Ago |
| Replies: 11 Views: 923 if ( ${cnt} -ge "1" ) That reads if cnt is greater or equal to 1 therefore != would have not worked.
if ($cnt >= 1) then
# whatever you want to mail
endif |
Forum: Shell Scripting 22 Days Ago |
| Replies: 11 Views: 923 csh doesn't use if/fi but rather if/endif. Look at posted script and you'll see you have an if/fi.
BTW csh doesn't have the same conditional operators than bash so -ge doesn't work. |
Forum: Shell Scripting 25 Days Ago |
| Replies: 11 Views: 923 Post your code the way you wrote it to execute. Make sure there's a space between [ and ] |
Forum: Shell Scripting 26 Days Ago |
| Replies: 5 Views: 587 It makes a difference the quotation scheme.
sed "/$npname.*in/d" parts.txt > parts.tmp |
Forum: Shell Scripting May 27th, 2009 |
| Replies: 4 Views: 1,094 blackrobe> Can you please give me an example on how to use the "sed" command in this case??...
I can do better than that, I will give you a link to an easy to understand tutorial... |
Forum: Shell Scripting Apr 19th, 2009 |
| Replies: 10 Views: 1,171 I am afraid that command doesn't produce the advertised result. |
Forum: Shell Scripting Apr 19th, 2009 |
| Replies: 10 Views: 1,171 >Anyway, one more favor, care to explain
It would require a base understanding that would take some time to write. Fortunately, others has done it already. Take a look at this link... |
Forum: Shell Scripting Apr 9th, 2009 |
| Replies: 10 Views: 1,171 >But, I'll still look for that [one-liner].
Because originally you used the switch -i I assumed your version of sed was GNU.
Thus sed -ie "0,/$JOBNAMES/{//d;}" filename should have work.
However,... |
Forum: Shell Scripting Apr 8th, 2009 |
| Replies: 10 Views: 1,171 Instead of :
sed -ie "\|^$JOBNAME\$|d"
try:
sed -ie "0,/$JOBNAMES/{//d;}" filename
The workhorse bit is "0,/RE/". It looks from starting line until first occurrence of REGEX
>I really am... |
Forum: Shell Scripting Mar 24th, 2009 |
| Replies: 11 Views: 1,608 >any ideas?
I am not running any version of Solaris so I don't know what's the "gotcha."
But if sprintf() is doing the job after the suffix "GB" is erased, let's do it.
Make an awk file that... |
Forum: Shell Scripting Mar 20th, 2009 |
| Replies: 11 Views: 1,608 >So sprint if getting the values however they still have either MB or GB on the end so therefore the sprintf statement wouldnt work would it?
Yes, it would. sprintf() tries to read and convert any... |
Forum: Shell Scripting Mar 20th, 2009 |
| Replies: 11 Views: 1,608 You get that result because sprintf is not receiving any value in column $2 that can convert into a decimal.
For debugging purposes substitute every line with a sprintf() call for just a print of $2... |
Forum: Shell Scripting Mar 19th, 2009 |
| Replies: 11 Views: 1,608 Assuming data format:
For example purposes coming from datafile to awk and displaying to standard output. Modify to need.
awk '/s/ {
if ( index($2, "GB") ) {
$2 =... |
Forum: Shell Scripting Mar 18th, 2009 |
| Replies: 4 Views: 1,173 Try this and see if you can figure out:
echo "2.3 4.56789" | awk '{printf "%.2f %.2f\n", $1, $2}' |
Forum: Shell Scripting Feb 10th, 2009 |
| Replies: 9 Views: 1,209 >What does the e+11 and e+10 mean??
Search for scientific notation. When a number is large in length (very big or very small), a method has been invented to represent it using exponent. |
Forum: Shell Scripting Jan 26th, 2009 |
| Replies: 7 Views: 2,120 John, Manager, Finance, $2000
Jack, Accountant, Finance, $1500
If you take off the $ sign from the field value it might work.
[Edit] Don't disregard Salem's advice. You're lucky I didn't... |
Forum: Shell Scripting Jan 24th, 2009 |
| Replies: 9 Views: 1,209 result=$(echo $var1 $var2 | awk '{print $1 - $2}')
$1 inside awk becomes whatever variable you past first, and $2 becomes the second variable and so on.
More about awk... |
Forum: Shell Scripting Jan 24th, 2009 |
| Replies: 9 Views: 1,209 >That gives me the following error
Yeap, expr doesn't support floating points
In bash you'll need to use bc, calc, awk, or perl
But ksh-93 supports floating points
result=$(((($obyte2 - $obyte1)... |
Forum: Shell Scripting Jan 23rd, 2009 |
| Replies: 9 Views: 1,209 Variables in the shell are strings. Another utility is necessary to make the evaluation.
expr can do it, but has many "gotchas" that you need to be aware of, e.i. spaces, (), *, which need to be... |
Forum: Shell Scripting Jan 20th, 2009 |
| Replies: 4 Views: 1,465 Whenever you log-in or open a new terminal window that starts the shell to run, a series of scripts are executed to establish the environment in which it is to run. These scripts contains commands... |
Forum: Shell Scripting Jan 9th, 2009 |
| Replies: 16 Views: 5,497 >This is strange, I've always thought because, if they didn't want you to edit your crontab file on the fly, why do they include the -e option to do just that?
My understanding is that by using... |
Forum: Shell Scripting Jan 5th, 2009 |
| Replies: 7 Views: 2,161 You don't need cat to display the content of `$line".sh"' to sed, in order to substitute some text.
sed 's/ordprg/new_string/g' $line".sh" > $line".sh" redirecting to the same file you have... |
Forum: Shell Scripting Dec 13th, 2008 |
| Replies: 6 Views: 2,377 sed needs to be told that test is not a substring but a word:\<word_here\>will do that. Once the pattern is matched, it deletes from that line to the end of the following one.
sed -e... |