User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
DaniWeb is a massive community of 391,768 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,155 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Showing results 1 to 40 of 49
Search took 0.01 seconds.
Posts Made By: radoulov
Forum: Shell Scripting May 24th, 2008
Replies: 4
Views: 769
Posted By radoulov
Re: HTTP server in bash

Check this link (http://home.eol.ca/~parkw/index.html#httpd.sh).
Forum: Shell Scripting May 23rd, 2008
Replies: 2
Views: 427
Posted By radoulov
Re: Variable check

With ksh93, bash, zsh:

[[ $VAR == L* ]]&&echo OK||echo KO

For old shells use case:

case $VAR in L*) echo OK;;*)echo KO;;esac
Forum: Shell Scripting May 9th, 2008
Replies: 2
Views: 467
Posted By radoulov
Re: Uniq on certain fields

Use nawk or /usr/xpg4/bin/awk on Solaris.

awk -F, '!x[$2,$4]++' input
Forum: Shell Scripting May 1st, 2008
Replies: 5
Views: 516
Posted By radoulov
Re: Script to search numbers from a given range from a file

awk 'END {
for (i=min; i<=max; i++)
if (!(i in x)) print i }
{ x[$1] }
' min=1 max=120 file
Forum: Shell Scripting Apr 30th, 2008
Replies: 8
Views: 1,476
Posted By radoulov
Re: Awk, using variables in a regular expression

Did you test your code?
Do you get the expected result?
Forum: Shell Scripting Apr 29th, 2008
Replies: 8
Views: 1,476
Posted By radoulov
Re: Awk, using variables in a regular expression

You could:

awk 'END {
print "#links:", _
for (i=1;i<=_;i++)
print la[i]
print "#images:", __
for (i=1;i<=__;i++)
print ia[i] }
{ r = $0
Forum: Shell Scripting Apr 28th, 2008
Replies: 8
Views: 1,476
Posted By radoulov
Re: Awk, using variables in a regular expression

If you have GNU Awk:

awk 'END {
print "#links:", _
for (i=1;i<=_;i++)
print la[i]
print "#images:", __
for (i=1;i<=__;i++)
print ia[i] }
{ r = $0
Forum: Shell Scripting Apr 28th, 2008
Replies: 8
Views: 1,476
Posted By radoulov
Re: Awk, using variables in a regular expression

Could you post a sample html input and the desired output?
Forum: Shell Scripting Feb 1st, 2008
Replies: 13
Views: 1,538
Posted By radoulov
Re: tell is $something has value

Or, if you prefer:

bash 3.2.33(18)$ unset VHOME
bash 3.2.33(18)$ [ ! -n "$VHOME" ]&&echo '$VHOME is unset or null'||echo '$VHOME is:' $VHOME
$VHOME is unset or null
bash 3.2.33(18)$ VHOME=a
bash...
Forum: Shell Scripting Feb 1st, 2008
Replies: 13
Views: 1,538
Posted By radoulov
Re: tell is $something has value

bash 3.2.33(18)$ :"${VHOME:-$(echo "I'm your code">pippo)}"
bash 3.2.33(18)$ cat pippo
I'm your code
Forum: Shell Scripting Feb 1st, 2008
Replies: 13
Views: 1,538
Posted By radoulov
Re: tell is $something has value

Or:

"${VHOME:-Empty, use this}"
Forum: Shell Scripting Jan 29th, 2008
Replies: 3
Views: 555
Posted By radoulov
Re: Replacing characters in a foldername

find . -depth -type d -exec sh -c 'p="${1%/*}"
d="${1##*/}"
[ ! -d "$p/${d//[§√^]/_}" ]&&mv "$p/$d" "$p/${d//[§√^]/_}"' - {} \;
Forum: Shell Scripting Jan 29th, 2008
Replies: 3
Views: 555
Posted By radoulov
Re: Replacing characters in a foldername

With bash,ksh93 and zsh:

$ ls -l
total 12K
drwxr-xr-x 2 radoulov radoulov 4.0K 2008-01-29 15:00 G^ran_F_080122/
drwxr-xr-x 2 radoulov radoulov 4.0K 2008-01-29 15:00 G§ran_F_08023/
drwxr-xr-x 2...
Forum: Shell Scripting Jan 15th, 2008
Replies: 3
Views: 1,327
Posted By radoulov
Re: Multiple spaces condense in shell script variable?

You'll find the answer here (http://www.grymoire.com/Unix/Quote.html).
Forum: Shell Scripting Jan 15th, 2008
Replies: 3
Views: 1,327
Posted By radoulov
Re: Multiple spaces condense in shell script variable?

Quote your variable: use "$line", not $line.
Forum: Shell Scripting Jan 15th, 2008
Replies: 3
Views: 2,012
Posted By radoulov
Re: Finding a Sub String

Or just:

$ awk '{print substr($0,index($0,v),length(v))}' v="$OK"<<<$HTML
OK

or
$ awk '{match($0,v);print substr($0,RSTART,RLENGTH)}' v="$OK"<<<$HTML
OK
Forum: Shell Scripting Jan 10th, 2008
Replies: 2
Views: 427
Posted By radoulov
Re: Need help in setting up as script..

printf "%s\n" "$(tail -1 fileA)">>fileB

Or perhaps I misread the question :)

Otherwise:

printf "%s\n" "$(grep -vf fileB fileA)">>fileB
Forum: Shell Scripting Dec 28th, 2007
Replies: 6
Views: 865
Posted By radoulov
Re: Help! i need to edit .* files in a particular directory

The splitting would be caused by the unnecessary ls, if you use just globbing (for x in *"$ext" ...) that won't happen.
Of course, rm *.psd is the way to go, as long as the args size doesn't hit the...
Forum: Shell Scripting Dec 21st, 2007
Replies: 2
Views: 952
Posted By radoulov
Re: email log parsing

awk 'NF>1&&!x[$2]++{print $2}' FS="username=[^@]*@" logfile

Use nawk or /usr/xpg4/bin/awk on Solaris.
Forum: Shell Scripting Dec 13th, 2007
Replies: 5
Views: 762
Posted By radoulov
Re: How to include real variables?

If you have zsh:

% n=0.1
% repeat 10 printf "%.2f\n" $((n+=0.1))
0.20
0.30
0.40
0.50
0.60
0.70
Forum: Shell Scripting Dec 12th, 2007
Replies: 3
Views: 1,299
Posted By radoulov
Re: shell script help

Line by line:

[ $# -ne 1 ]&&{
printf "Usage %s [%s]\n" "$0" "host"
exit 1
}

Test if the number of arguments supplied ($#) is not 1 (-ne stands for not equal),
if so (&& - if the previous...
Forum: Shell Scripting Dec 12th, 2007
Replies: 3
Views: 1,299
Posted By radoulov
Re: shell script help

#!/bin/sh
[ $# -ne 1 ]&&{
printf "Usage %s [%s]\n" "$0" "host"
exit 1
}
whois "$1"|fgrep "Name Server"|while read ns;do
printf "%s\n" "${ns# }"
done
dig +short "$1" mx|while read j...
Forum: Shell Scripting Dec 9th, 2007
Replies: 2
Views: 1,599
Posted By radoulov
Re: reading lines from text file and formating them

With Awk:

awk '/^Items/{sub(/Items purchased by /,"");store=$1}
/^[0-9]/{printf "%s %s\n",store,$0}' FS=":" store-orders.txt>your_new_file.txt

Use nawk or /usr/xpg4/bin/awk on Solaris.
Forum: Shell Scripting Nov 27th, 2007
Replies: 1
Views: 1,058
Posted By radoulov
Forum: Shell Scripting Nov 27th, 2007
Replies: 3
Views: 1,263
Posted By radoulov
Re: how to access variable outside awk and spliting the string in array

Strange,
what is the output of the following block on your system, here's mine:

$ ls -l myinfo/yourinfo/supplierinfo/*Collector.java
-rw-r--r-- 1 radoulov radoulov 0 2007-11-27 09:48...
Forum: Shell Scripting Nov 26th, 2007
Replies: 3
Views: 1,263
Posted By radoulov
Re: how to access variable outside awk and spliting the string in array

If I understand correctly all you need is just:

for prog in /myinfo/yourinfo/supplierinfo/*Collector.java;do
progname="${prog##*/}"
java -classpath "$CLASSPATH:." "${progname%.java}"
done
Forum: Shell Scripting Nov 24th, 2007
Replies: 3
Views: 788
Posted By radoulov
Re: Helpless in shell sorting

Who is giving you such assignments :)

If the output should be really as the one you show:

sort -t" " -rk2.12,2.14 filename | awk '
/^1/ { sub(/1/, "2") }
/^3/ { saved = $0 }
/^0/ { $NF = ($NF FS...
Forum: Shell Scripting Nov 6th, 2007
Replies: 10
Views: 1,373
Posted By radoulov
Re: Replace

On Solaris it should work with nawk and /usr/xpg4/bin/awk.

Tested with

/usr/bin/nawk:
SunOS 5.8 Generic 111111-04 Mar 2004

/usr/xpg4/bin/awk:
SunOS 5.8 Generic February 2000
Forum: Shell Scripting Nov 5th, 2007
Replies: 10
Views: 1,373
Posted By radoulov
Re: Replace

Sed is not the right tool for this:

awk '/^127/{sub(/^127\./,"&"c" ");c++}1' A.txt
Forum: Shell Scripting Nov 5th, 2007
Replies: 10
Views: 1,373
Posted By radoulov
Re: Replace

Assuming "127" as pattern to match and an input as the one posted above:

awk '/127/{$1=$1c;c++}1' A.txt>B.txt

Note that $1=$1... will recalculate the current record and squeeze repeated FS...
Forum: Shell Scripting Oct 18th, 2007
Replies: 3
Views: 922
Posted By radoulov
Re: Echoing the highest of ten inputed numbers.

With zsh:

% set -- 03 32 156 4 593 2 033 490 5 12
% print ${${(n)@}[-1]}
593

with sort:

$ numbers="03 32 156 4 593 2 033 490 5 12"
$ set -- $(printf "%d\n" $numbers|sort -nr)
Forum: Shell Scripting Oct 16th, 2007
Replies: 1
Views: 1,102
Posted By radoulov
Re: problem with redirecting error from function

The implementation depends on the shell you're using,
with recent versions of bash and with ksh93 you can use the pipefail option:
bash 3.2.25(1)$ f(){ ls "$@" 2>/dev/null||return $?;}
bash...
Forum: Shell Scripting Oct 12th, 2007
Replies: 2
Views: 1,244
Posted By radoulov
Re: string manipulation

With bash/ksh93 and zsh:

% s="c0024"
% echo "${s//[^0-9]}"
0024
Forum: Shell Scripting Oct 2nd, 2007
Replies: 6
Views: 720
Posted By radoulov
Re: Help with sed command please.

You will get the modified output, you just have to save it,
or, if you have the GNU sed, you could use the -i switch to modify the file in-place.
Forum: Shell Scripting Oct 2nd, 2007
Replies: 6
Views: 720
Posted By radoulov
Re: Help with sed command please.

zsh 4.3.4% echo "Page 1 1"|sed '/Page 1 1/i\
currentpagedevice /InputAttributes get 0 get\
dup null eq\
{ pop }\
{ dup length 1 add dict copy\
dup /InputAttributes\
1 dict dup /Priority [0 1 2 3]...
Forum: Shell Scripting Oct 2nd, 2007
Replies: 1
Views: 709
Posted By radoulov
Re: Comparing 2 files and then apending matches

If you want the records that don't match also:

awk 'NR==FNR{x[$2]=$NF;next}
$1 in x?$0=$0" "x[$1]:1' FS="[~ ]" file2 file1

Without them:

awk 'NR==FNR{x[$2]=$NF;next}
$1 in x?$0=$0" "x[$1]:0'...
Forum: Shell Scripting Sep 26th, 2007
Replies: 1
Views: 1,552
Posted By radoulov
Re: script to move files that are not in use or open

Adjust *.log for your needs (you may include the path: /your/path/*.log):

for f in *.log;do fuser "$f">/dev/null 2>&1||rm -- "$f";done
Forum: Shell Scripting Sep 14th, 2007
Replies: 5
Views: 772
Posted By radoulov
Re: how to get............

This is almost always the wrong way:
in this case:
1. you don't need to call external commands("ls")
2. you need to quote the varible (and you don't need braces ("{}"))
Your script will fail if the...
Forum: Shell Scripting Sep 13th, 2007
Replies: 5
Views: 772
Posted By radoulov
Re: how to get............

Or just:

head -1 *
Forum: Shell Scripting Sep 12th, 2007
Replies: 2
Views: 1,313
Posted By radoulov
Re: Korn Shell books for beginner

The Korn Shell (Unix and Linux Program Manual)...
Showing results 1 to 40 of 49

 
All times are GMT -4. The time now is 4:30 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC