Search Results

Showing results 1 to 40 of 60
Search took 0.01 seconds.
Search: Posts Made By: ghostdog74 ; Forum: Shell Scripting and child forums
Forum: Shell Scripting 6 Days Ago
Replies: 9
Views: 399
Posted By ghostdog74
it depends on what errors you are looking for. If there are 1000s of errors, are you going to send all 1000 ++ errors to your email?? you have to describe clearly your specs.
Forum: Shell Scripting May 23rd, 2009
Replies: 5
Views: 894
Posted By ghostdog74
use awk

awk '/default = ALL/{
print "default = DES-168"
print "default = RC2-128"
print "default = RC4-128"
print "#"$0
next}1' file
Forum: Shell Scripting Apr 15th, 2009
Replies: 3
Views: 1,241
Posted By ghostdog74
you may search the CPAN library for Audio::Taglib. ( there are others, so pls do a search).
Forum: Shell Scripting Apr 15th, 2009
Replies: 3
Views: 1,241
Posted By ghostdog74
if you have Perl, you can use the MP3::Tag module.
eg

use MP3::Tag;
# set filename of MP3 track
my $filename = "test.mp3";
# create new MP3-Tag object
my $mp3 = MP3::Tag->new($filename);
#...
Forum: Shell Scripting Mar 27th, 2009
Replies: 4
Views: 1,058
Posted By ghostdog74
regular expressions are usually not needed for string manipulations.

# echo "abcdd" | awk 'BEGIN{FS=""}$2==$3{print "ok"}'
# echo "abbdd" | awk 'BEGIN{FS=""}$2==$3{print "ok"}'
ok
Forum: Shell Scripting Mar 17th, 2009
Replies: 2
Views: 1,199
Posted By ghostdog74
awk '{printf "%s %s",$0, ($3 > 40)? "yes" :"no"}' file
Forum: Shell Scripting Sep 15th, 2008
Replies: 7
Views: 1,491
Posted By ghostdog74
you can do everything in awk

ps -C bash -o size= | awk '{sum+=$1}END{ print (sum>65535 ? "exceeded":"not exceeded") }'
Forum: Shell Scripting Aug 19th, 2008
Replies: 2
Views: 1,035
Posted By ghostdog74
better still, no need grep

top | awk '/root/{ sum += $10 }END {print sum}'
Forum: Shell Scripting Jul 25th, 2008
Replies: 6
Views: 2,327
Posted By ghostdog74
Look at the bash guide here (http://tldp.org/LDP/abs/html/testbranch.html). It has examples on checking for upper case.
Forum: Shell Scripting Jul 25th, 2008
Replies: 6
Views: 1,138
Posted By ghostdog74
sed will be slower than tail for huge files. Just a tip
Forum: Shell Scripting Jun 24th, 2008
Replies: 6
Views: 1,038
Posted By ghostdog74
awk 'BEGIN{FS="[: ]"}
/Name/{ name=$3 }
/Active/ && /Yes/{
cmd = "mailx -s \""name " is active\" body root"
system(cmd)
}
' file
Forum: Shell Scripting Jun 11th, 2008
Replies: 3
Views: 3,101
Posted By ghostdog74
do it using awk's srand() and rand().

awk 'BEGIN{
srand()
num=int(rand() * 10) + 1
}
NR==num' file
Forum: Shell Scripting Jun 4th, 2008
Replies: 2
Views: 1,331
Posted By ghostdog74
if TEST2 is the second field and no where else and you want to replace only that second field,

awk 'NR==4{$2="DEV"}1' file
Forum: Shell Scripting Jun 3rd, 2008
Replies: 2
Views: 2,641
Posted By ghostdog74
awk 'BEGIN{FS=""}NR==1{print $1}{l=$NF}END{print l}' file
Forum: Shell Scripting Apr 14th, 2008
Replies: 3
Views: 1,310
Posted By ghostdog74
don't use useless cat with while loop

while read -r line
do
#processing
done < "file"
'

anyway, here's another way to solve your problem
Forum: Shell Scripting Apr 13th, 2008
Replies: 1
Views: 842
Posted By ghostdog74
# grep -f file -v file1
D
E
Forum: Shell Scripting Apr 10th, 2008
Replies: 13
Views: 2,792
Posted By ghostdog74
have you read the line i gave about while loops? pseudocode.

while read -r name number
do
while read -r NAME NUM
do
if NAME is equal name
then
echo...
Forum: Shell Scripting Apr 9th, 2008
Replies: 13
Views: 2,792
Posted By ghostdog74
try this document (http://tldp.org/LDP/abs/html/loops1.html) instead. almost all you need to know about shell
Forum: Shell Scripting Apr 9th, 2008
Replies: 13
Views: 2,792
Posted By ghostdog74
what have you learnt in that online class so far? do you have lecture notes and books for shell scripting?
Forum: Shell Scripting Apr 9th, 2008
Replies: 6
Views: 2,395
Posted By ghostdog74
if you are really developing an intranet application, then ask the administrator to assign you the proper rights to those commands necessary for your work. don't try anything that is not allowed by...
Forum: Shell Scripting Apr 5th, 2008
Replies: 6
Views: 1,717
Posted By ghostdog74
no i am not. there are many who are better:)



this is where i learn AWK/SED (http://www.unix.org.ua/orelly/unix/sedawk/index.htm). Also grymoire (http://www.grymoire.com/Unix/) is worth a look
Forum: Shell Scripting Apr 5th, 2008
Replies: 6
Views: 1,717
Posted By ghostdog74
awk '$NF <=3 {a[NR]=$NF;c[a[NR]]=$0}
END{
n=asort(a,b)
print c[b[n]]
}' file

output:

# ./test.sh
18 126 2833 30 0.010479 2.842
Forum: Shell Scripting Apr 5th, 2008
Replies: 4
Views: 1,153
Posted By ghostdog74
use the -v option of awk to pass in shell variables so that you don't have to get too confused between shell and awk variables.
eg

awk -v archive="$ARCHIVE" ' {
print archive
# etc code...
Forum: Shell Scripting Mar 26th, 2008
Replies: 9
Views: 2,342
Posted By ghostdog74
no need to use cat

uuencode $file $file | /usr/bin/mailx -s "TEST"
Forum: Shell Scripting Mar 7th, 2008
Replies: 8
Views: 2,557
Posted By ghostdog74
awk 'BEGIN{FS="[]].[[]|[[]|[]]"}
{
gsub(/id|\"/,"",$13)
split($3,a,"/")
gsub("tag","",$16)
print $13,a[1],$7,$16
}' file
Forum: Shell Scripting Feb 24th, 2008
Replies: 1
Views: 1,488
Posted By ghostdog74
simply assign to a variable first


cmd = "useradd -G " var1 " -g " var2 " -m -s " $1 " -u " $2 " -K PASS_MIN_LEN=4 -K PASS_MAX_LEN=7 -p \047*\047" "usrname"
print cmd # to see if your cmd is...
Forum: Shell Scripting Jan 22nd, 2008
Replies: 3
Views: 52,661
Posted By ghostdog74
awk 'NR==1{ print "var="$1}' file
Forum: Shell Scripting Jan 15th, 2008
Replies: 3
Views: 11,755
Posted By ghostdog74
# echo $HTML | sed 's/<html><body>\(.*\)<\/body><\/html>/\1/'
OK
Forum: Shell Scripting Jan 14th, 2008
Replies: 3
Views: 1,268
Posted By ghostdog74
see my sig links for learning bash scripting. If you want to do floating point maths, you can use tools like bc.
Forum: Shell Scripting Jan 14th, 2008
Replies: 5
Views: 7,028
Posted By ghostdog74
for large number of files, basename/dirname may not be a good choice ( but its up to you). Using bash string operation may be more efficient as you don't need to call "external commands"
eg

#...
Forum: Shell Scripting Oct 30th, 2007
Replies: 3
Views: 1,291
Posted By ghostdog74
find /path -type f -name "status10.dat*" -mtime 0 -print0 | xargs -i -0 cp "{}" /cerner/d_p19/ccluserdir
Forum: Shell Scripting Oct 28th, 2007
Replies: 4
Views: 3,196
Posted By ghostdog74
a="2007-05-10"
b="2007-06-10"
awk -v a="$a" -v b="$b" 'BEGIN{
n=split(a,tmpa,"-")
m=split(b,tmpb,"-")
if ( ( tmpa[1] <= tmpb[1] ) && ( tmpa[2] <= tmpb[2] ) ){
print "correct"
}
else { print...
Forum: Shell Scripting Oct 28th, 2007
Replies: 7
Views: 2,256
Posted By ghostdog74
no need for cat

while read ....
do
....
done < inputfile.txt
Forum: Shell Scripting Oct 28th, 2007
Replies: 4
Views: 1,941
Posted By ghostdog74
it should not matter if you put $yr or ${yr}. Show your entire code that defined the variables..
Forum: Shell Scripting Sep 25th, 2007
Replies: 3
Views: 1,202
Posted By ghostdog74
since this is homework, i will show an example. you follow up with the rest.

awk '/<tag1>/ {
gsub("<tag1>|</tag1>","")
printf "%s|",$0
t1 = t1 sprintf("%s|",$0)
}END...
Forum: Shell Scripting Jun 14th, 2007
Replies: 2
Views: 2,587
Posted By ghostdog74
you can save your IP in a file. check for file existence and if exists, read it and save the IP contained in the file into variable. then check your IP, comparing it with the variable. If not the...
Forum: Shell Scripting Jun 11th, 2007
Replies: 2
Views: 2,395
Posted By ghostdog74
Forum: Shell Scripting Jun 7th, 2007
Replies: 7
Views: 11,877
Posted By ghostdog74
Forum: Shell Scripting Jun 4th, 2007
Replies: 10
Views: 3,956
Posted By ghostdog74
put a return statement in the functoin. then call it and use $? to catch the value


# function test() { return 1; }
# var=$(test)
# echo $?
1
Forum: Shell Scripting Jun 4th, 2007
Replies: 10
Views: 3,956
Posted By ghostdog74
try typing the commands on the shell prompt and see.
Showing results 1 to 40 of 60

 


About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC