Forum: Shell Scripting May 24th, 2008 |
| Replies: 4 Views: 769 |
Forum: Shell Scripting May 23rd, 2008 |
| Replies: 2 Views: 427 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 |
Forum: Shell Scripting May 1st, 2008 |
| Replies: 5 Views: 516 |
Forum: Shell Scripting Apr 30th, 2008 |
| Replies: 8 Views: 1,476 |
Forum: Shell Scripting Apr 29th, 2008 |
| Replies: 8 Views: 1,476 |
Forum: Shell Scripting Apr 28th, 2008 |
| Replies: 8 Views: 1,476 |
Forum: Shell Scripting Apr 28th, 2008 |
| Replies: 8 Views: 1,476 |
Forum: Shell Scripting Feb 1st, 2008 |
| Replies: 13 Views: 1,538 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 |
Forum: Shell Scripting Feb 1st, 2008 |
| Replies: 13 Views: 1,538 |
Forum: Shell Scripting Jan 29th, 2008 |
| Replies: 3 Views: 555 |
Forum: Shell Scripting Jan 29th, 2008 |
| Replies: 3 Views: 555 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 |
Forum: Shell Scripting Jan 15th, 2008 |
| Replies: 3 Views: 1,327 |
Forum: Shell Scripting Jan 15th, 2008 |
| Replies: 3 Views: 2,012 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 |
Forum: Shell Scripting Dec 28th, 2007 |
| Replies: 6 Views: 865 |
Forum: Shell Scripting Dec 21st, 2007 |
| Replies: 2 Views: 952 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 |
Forum: Shell Scripting Dec 12th, 2007 |
| Replies: 3 Views: 1,299 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 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 |
Forum: Shell Scripting Nov 27th, 2007 |
| Replies: 1 Views: 1,058 |
Forum: Shell Scripting Nov 27th, 2007 |
| Replies: 3 Views: 1,263 |
Forum: Shell Scripting Nov 26th, 2007 |
| Replies: 3 Views: 1,263 |
Forum: Shell Scripting Nov 24th, 2007 |
| Replies: 3 Views: 788 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 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 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 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 |
Forum: Shell Scripting Oct 16th, 2007 |
| Replies: 1 Views: 1,102 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 |
Forum: Shell Scripting Oct 2nd, 2007 |
| Replies: 6 Views: 720 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 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 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 |
Forum: Shell Scripting Sep 14th, 2007 |
| Replies: 5 Views: 772 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 |
Forum: Shell Scripting Sep 12th, 2007 |
| Replies: 2 Views: 1,313 |