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: 811
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: 435
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,573
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: 583
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,154
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,154
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: 982
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,083
Posted By ghostdog74
awk '{printf "%s %s",$0, ($3 > 40)? "yes" :"no"}' file
Forum: Python Sep 24th, 2008
Replies: 4
Views: 742
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,126
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,474
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,018
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,217
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,111
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,016
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,977
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,266
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,525
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,260
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: 826
Posted By ghostdog74
# grep -f file -v file1
D
E
Forum: Shell Scripting Apr 10th, 2008
Replies: 13
Views: 2,707
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,707
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,707
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,314
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,650
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,650
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,113
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,275
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,495
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,449
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: 50,411
Posted By ghostdog74
awk 'NR==1{ print "var="$1}' file
Forum: Shell Scripting Jan 15th, 2008
Replies: 3
Views: 10,994
Posted By ghostdog74
# echo $HTML | sed 's/<html><body>\(.*\)<\/body><\/html>/\1/'
OK
Forum: Shell Scripting Jan 14th, 2008
Replies: 3
Views: 1,259
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,900
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,269
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,106
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,236
Posted By ghostdog74
no need for cat

while read ....
do
....
done < inputfile.txt
Forum: Shell Scripting Oct 28th, 2007
Replies: 4
Views: 1,890
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,958
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,945
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