Search Results

Search: Posts Made By: venu
1,419
Posted By vbe
What is the "done" for? Is this an extract from...
What is the "done" for? Is this an extract from another script with a loop?
1,419
Posted By balajesuri
kill -9 `ps -ef | grep test.sh | grep -v grep |...
kill -9 `ps -ef | grep test.sh | grep -v grep | awk '{print $2}'`
stat=$?
if [ $stat -eq 0 ]
then
echo " script killed at $(date +%D@%T) "
else
echo " script process does not exists...
1,419
Posted By chidori
the way you are trying to kill is not correct!!
i have splitted your kill command and see what happens..

see what variable a holds in it ??

# a=`ps -ef |grep /usr/sbin/cron | grep -v grep`
# echo $a
root 438 1 0 Oct 20 2 g 0:02...
1,419
Posted By m.d.ludwig
Have you tried something like: echo kill `ps...
Have you tried something like:
echo kill `ps -ef |grep test.sh| grep -v grep`to see what arguments you are passing to kill.
Or even sh -x badscript?

If I would have to guess ... you are running...
8,580
Posted By otheus
Alright, so I was curious how to do this in bash,...
Alright, so I was curious how to do this in bash, having never myself attempted it. It's a bit tricky.

First, you can do the operation directly using "Arithmetic Expansion", ie $(( ... ))

$...
8,580
Posted By jim mcnamara
You cannot use bourne shell alone to do that. ...
You cannot use bourne shell alone to do that. bash has bitwise operators as builtins.
You will have to resort to another interpreted language like perl, or a compiled language like C, if you cannot...
4,989
Posted By vgersh99
depending on your definition of a 'word' -...
depending on your definition of a 'word' - YMMV...

sed 's# +#,&#g' myFile
4,989
Posted By durden_tyler
Here are a couple of Perl one-liners - $...
Here are a couple of Perl one-liners -


$
$ cat f41
The quick brown fox jumps over the lazy dog.
Mary had a little lamb.
Humpty Dumpty sat on a wall.
$
$
$ perl -plne 's/(\w+)/$1,/g' f41...
93,721
Posted By ahamed101
Since you are using a while loop, try this... ...
Since you are using a while loop, try this...

#!/bin/bash

i=1
while read line
do
test $i -eq 1 && ((i=i+1)) && continue
echo $line
done < infile


Using AWK

awk...
93,721
Posted By agama
Easiest way is to use sed: sed 1d $rpt |...
Easiest way is to use sed:


sed 1d $rpt | while read d
do
echo $d
done


The 1d causes the first line to be deleted and sed writes the rest to stdout.
3,273
Posted By vishalaswani
You can save the argument which is being passed...
You can save the argument which is being passed to script B in a file everytime script A gets executed.

Here is an example.


Script A

LOC="Where you want to save the argument counter...
10,881
Posted By joeyg
Does this give you some ideas?
$ echo trousers:shirts,price,50 | awk -F"," '{print $3 " " $1 "." $2}'
50 trousers:shirts.price


Instead of an echo, you could pass the input file to that awk command.
16,353
Posted By Chubler_XL
This will get you the 5th line sed -n 5p infile...
This will get you the 5th line
sed -n 5p infile

To check for "string" in 5th line:

awk 'NR==5&&/string/ {exit 1}' infile || echo "Found it!"
8,819
Posted By methyl
What Operating System(s) are you running? Please...
What Operating System(s) are you running? Please be specific and detail any additional packages or other hooks which you may have installed. There is no way that a standard M$ Windows at any version...
25,657
Posted By Scrutinizer
$ echo ${mask#2#} | awk...
$ echo ${mask#2#} | awk '{for(i=1;i<=NF;i++)if($i)print i-1}' FS=
0
13
24
30But shouldn't the position be determined from right to left?
$ echo ${mask#2#} | awk '{for(i=NF;i>=1;i--)if($i)print...
25,657
Posted By ctsgnb
Oh ! ... i never noticed this before ~ is...
Oh ! ... i never noticed this before
~ is described as "Bitwise not" in oreilly ksh book ... but it is not the behaviour i see, xor 1 should be used instead

$ echo $SHELL
/bin/ksh
$...
25,657
Posted By Chubler_XL
OK if you have gawk and ksh: $ cat bits.awk...
OK if you have gawk and ksh:

$ cat bits.awk
#!/bin/ksh
echo $1 | gawk --non-decimal-data ' {
for(i=lshift(1,31);i;i=rshift(i,1))
printf "%d%s", (and(("0x"$1)+0,i) > 0), ++c%4==0?" ":"";...
25,657
Posted By fpmurphy
If your Korn shell is a recent version of ksh93,...
If your Korn shell is a recent version of ksh93, try the following

#!/bin/ksh93

integer -i2 mask=16#F0000000
integer -i2 v0 v1 v2 v3 v4 v5 v6 v7

read hn?"Enter a 32-bit hex decimal number:...
25,657
Posted By Chubler_XL
Why not put the bits in an array? (you will...
Why not put the bits in an array? (you will probably find them easier to work with in your script later):

$ eval B="( $(echo 1000000000000100000000001000001 | sed 's/./& /g') )"

$ for ((i=0;...
25,657
Posted By ctsgnb
$ echo "1000000000000100000000001000001" | sed...
$ echo "1000000000000100000000001000001" | sed 's/ */ /g;s/^ //;s/ $//' | tr ' ' '\n' | cat -n |sed '/0$/d;/1$/s/^[[:blank:]]*/b/;s/[[:blank:]]1/=1/'
b1=1
b14=1
b25=1
b31=1
$
25,657
Posted By Chubler_XL
If you have gawk and bash: $ cat bits.awk ...
If you have gawk and bash:

$ cat bits.awk
#!/bin/bash
echo $((16#$1)) | gawk ' {
for(i=lshift(1,31);i;i=rshift(i,1))
printf "%d%s", (and($1,i) > 0), ++c%4==0?" ":"";
printf"\n"; }'

$...
25,657
Posted By rdcwayx
$ cat hex2bin.awk BEGIN { FS="" ...
$ cat hex2bin.awk

BEGIN {
FS=""
a["f"]="1111"
a["e"]="1110"
a["d"]="1101"
a["c"]="1100"
a["b"]="1011"
a["a"]="1010"
a["9"]="1001"
a["8"]="1000"
a["7"]="0111"
a["6"]="0110"...
25,657
Posted By frank_rizzo
simple example using bc. parse the output into...
simple example using bc. parse the output into whatever you want

$ bc <<EOF
> ibase=16
> obase=2
> FFFF
> EOF
1111111111111111
25,657
Posted By fpmurphy
I think the first question is what scripting...
I think the first question is what scripting language do you wish to use?
Showing results 1 to 24 of 24

 
All times are GMT -4. The time now is 12:36 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy