Forum: Shell Scripting Mar 23rd, 2009 |
| Replies: 3 Views: 520 while IFS= read -r;do
printf '%s\n' "$REPLY"
done<regex.txt |
Forum: Shell Scripting Mar 7th, 2009 |
| Replies: 1 Views: 741 du -ks /home/*/ 2>&- |
while read s d; do
u="${d%/}"
[ "$s" -gt 51200 ] &&
printf '%s: %d kb\n' "$d" "$s" |
mail -s "your home dir is too big ..." "${u#/home/}"
done |
Forum: Shell Scripting Sep 7th, 2008 |
| Replies: 6 Views: 2,568 Yep, sorry!
It was a typo,
I meant:
echo "$*" >> jmj.txt |
Forum: Shell Scripting Sep 5th, 2008 |
| Replies: 6 Views: 2,568 Try changing the shell script to:
echo "$#" >> jmj.txt |
Forum: Shell Scripting Sep 4th, 2008 |
| Replies: 6 Views: 2,568 If you can quote your parameters:
% cat s
#!/usr/bin/sh
ls -l "$1"
% ./s "pip po"
-rw-r--r-- 1 sysadmin None 0 Sep 4 11:46 pip po
Otherwise (assuming single parameter): |
Forum: Shell Scripting May 24th, 2008 |
| Replies: 4 Views: 2,079 Check this link (http://home.eol.ca/~parkw/index.html#httpd.sh). |
Forum: Shell Scripting May 23rd, 2008 |
| Replies: 2 Views: 776 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: 1,191 Use nawk or /usr/xpg4/bin/awk on Solaris.
awk -F, '!x[$2,$4]++' input |
Forum: Shell Scripting May 1st, 2008 |
| Replies: 5 Views: 926 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: 5,963 Did you test your code?
Do you get the expected result? |
Forum: Shell Scripting Apr 29th, 2008 |
| Replies: 8 Views: 5,963 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: 5,963 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: 5,963 Could you post a sample html input and the desired output? |
Forum: Shell Scripting Feb 1st, 2008 |
| Replies: 13 Views: 2,932 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... |
Forum: Shell Scripting Feb 1st, 2008 |
| Replies: 13 Views: 2,932 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: 2,932 Or:
"${VHOME:-Empty, use this}" |
Forum: Shell Scripting Jan 29th, 2008 |
| Replies: 3 Views: 1,131 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: 1,131 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: 2,940 You'll find the answer here (http://www.grymoire.com/Unix/Quote.html). |
Forum: Shell Scripting Jan 15th, 2008 |
| Replies: 3 Views: 2,940 Quote your variable: use "$line", not $line. |
Forum: Shell Scripting Jan 15th, 2008 |
| Replies: 3 Views: 11,162 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: 959 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: 1,667 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... |
Forum: Shell Scripting Dec 21st, 2007 |
| Replies: 2 Views: 1,986 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: 1,668 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: 2,918 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: 2,918 #!/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: 3,925 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: 2,401 |
Forum: Shell Scripting Nov 27th, 2007 |
| Replies: 3 Views: 2,582 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: 2,582 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: 1,438 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 =... |
Forum: Shell Scripting Nov 6th, 2007 |
| Replies: 10 Views: 2,060 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... |
Forum: Shell Scripting Nov 5th, 2007 |
| Replies: 10 Views: 2,060 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: 2,060 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: 1,398 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... |
Forum: Shell Scripting Oct 16th, 2007 |
| Replies: 1 Views: 2,198 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: 2,899 With bash/ksh93 and zsh:
% s="c0024"
% echo "${s//[^0-9]}"
0024 |
Forum: Shell Scripting Oct 2nd, 2007 |
| Replies: 6 Views: 1,343 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: 1,343 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... |