Search Results

Showing results 1 to 40 of 148
Search took 0.01 seconds.
Search: Posts Made By: ghostdog74
Forum: Shell Scripting May 23rd, 2009
Replies: 5
Views: 787
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: Perl Apr 21st, 2009
Replies: 4
Views: 427
Posted By ghostdog74
you can learn the basics of Perl first. One of the many good sources is straight from the doc. type perldoc perl for more info. otherwise, you can always view online Perl doc with your browser....
Forum: Perl Apr 21st, 2009
Replies: 12
Views: 1,513
Posted By ghostdog74
# perl -ne 'print if !(/\[SectionOne\]/ .. /\[SectionTWO\]/); ' file

Entry1=19
Entry2=hello there



use module like Config::IniFiles is still the best.
Forum: Perl Apr 17th, 2009
Replies: 4
Views: 562
Posted By ghostdog74
i think you shouldn't need to worry too much on whether its the correct directory because you would have set it properly when configuring your FTP server.
Forum: Shell Scripting Apr 15th, 2009
Replies: 3
Views: 1,115
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,115
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: 923
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,031
Posted By ghostdog74
awk '{printf "%s %s",$0, ($3 > 40)? "yes" :"no"}' file
Forum: Python Sep 24th, 2008
Replies: 4
Views: 716
Posted By ghostdog74
without glob module, just search for it

import os
os.chdir("/somewhere")
for files in os.listdir("."):
if not "_ab" in files:
print files
Forum: IT Professionals' Lounge Sep 16th, 2008
Replies: 7
Views: 2,094
Posted By ghostdog74
you can use the script here (http://www.linuxquestions.org/linux/blog/ghostdog74/2008-09-13/Mass_File_Renamer_By_Pattern_Substitution)
eg usage

# ./script.sh -s "4%3a" -e "" -d "*.deb" # display...
Forum: Shell Scripting Sep 15th, 2008
Replies: 7
Views: 1,463
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: 994
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,170
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,100
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,008
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: 2,909
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,228
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,461
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,231
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: 821
Posted By ghostdog74
# grep -f file -v file1
D
E
Forum: Shell Scripting Apr 10th, 2008
Replies: 13
Views: 2,673
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,673
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,673
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,272
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,619
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,619
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,096
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,249
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,468
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,425
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: 49,259
Posted By ghostdog74
awk 'NR==1{ print "var="$1}' file
Forum: Shell Scripting Jan 15th, 2008
Replies: 3
Views: 10,636
Posted By ghostdog74
# echo $HTML | sed 's/<html><body>\(.*\)<\/body><\/html>/\1/'
OK
Forum: Shell Scripting Jan 14th, 2008
Replies: 3
Views: 1,252
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: 6,828
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,253
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,072
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,216
Posted By ghostdog74
no need for cat

while read ....
do
....
done < inputfile.txt
Forum: Shell Scripting Oct 28th, 2007
Replies: 4
Views: 1,868
Posted By ghostdog74
it should not matter if you put $yr or ${yr}. Show your entire code that defined the variables..
Forum: Python Sep 25th, 2007
Replies: 2
Views: 1,927
Posted By ghostdog74
why do you think that regular expression is the way to go?

>>> s1 ='&nbsp;25000&nbsp;'
>>> s1.replace("&nbsp;","")
'25000'
>>> s2 = '&nbsp;5.5910&nbsp;'
>>> s2.replace("&nbsp;","")
'5.5910'
...
Forum: Python Sep 25th, 2007
Replies: 4
Views: 2,903
Posted By ghostdog74
it would be better to show a sample input file, your expected output as well.
to search in a file. just an example...considering i don't know what your file structure is like.

for line in...
Showing results 1 to 40 of 148

 


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

©2003 - 2009 DaniWeb® LLC