Forum: Shell Scripting Jan 10th, 2008 |
| Replies: 3 Views: 2,068 date -u causes UTC date/time to be displayed - FYI.
If you format date like this:
today=$(date +%Y%m%d)
you get a value like 20080111, this is a number - an integer.
When you split the input... |
Forum: Shell Scripting Jun 25th, 2007 |
| Replies: 4 Views: 1,751 http://www.freebsd.org/cgi/man.cgi?query=sysexits&apropos=0&sektion=0&manpath=FreeBSD+4.3-RELEASE&format=html |
Forum: Shell Scripting May 29th, 2007 |
| Replies: 2 Views: 1,343 for i in $(cut -f 1,3 -d: /etc/passwd)
do
echo "${i#*:}" "${i%:*}"
done
This lets you see what is going on. ${i#*:} is parameter substitution- returns the value just before the colon -... |
Forum: Shell Scripting May 8th, 2007 |
| Replies: 1 Views: 1,299 try:
#!/bin/ksh
export infile=filename
filedate()
{
perl -e '
use Time::Local;
$mytime = timelocal(0,$ARGV[4],$ARGV[3],$ARGV[1], |
Forum: Shell Scripting Mar 6th, 2007 |
| Replies: 4 Views: 1,841 You have to use either ksh (zsh) or bash to do this - ie., a modern shell with pattern matching.
cd /path/to/files
find . -name '*.err' |\
while read file
do
tmp=${file%%.das*}
mv $file... |
Forum: Shell Scripting Feb 13th, 2007 |
| Replies: 1 Views: 1,326 try:
#
find $1 -type f -exec grep -l -e '/*' -e '//' {} \; |
while read file
do
grep -q ';' $file
if [[ $? -ne 0 ]] ; then
echo $file | grep -q -e '\.c$' -e '\.h$'... |
Forum: Shell Scripting Jan 26th, 2007 |
| Replies: 3 Views: 4,481 sed 'n;s/$/;/' filename > newfilename |
Forum: Shell Scripting Jan 26th, 2007 |
| Replies: 3 Views: 2,112 You need to use sed, and you have to learn about regular expressions.
based on your data a very specific (not generalized) solution is:
$> echo "Here's some text and ~this bit gets removed~,... |
Forum: Shell Scripting Jan 26th, 2007 |
| Replies: 1 Views: 2,264 This will generate a report like you asked for.
nawk '
{ shortcode[$11]=$11
causecode[$12]=$12
result[$11 $12]++
}
END{ for( short in shortcode)
{... |
Forum: Shell Scripting Jan 17th, 2007 |
| Replies: 3 Views: 3,297 It looks like you're trying to automate vi.
There are such things as "ed scripts" - scripts that invoke the ed editor.
You can use that scripting language easily. vi presents problems because it... |
Forum: Shell Scripting Jan 5th, 2007 |
| Replies: 4 Views: 5,015 Why loop? you only need two rsh lines. You gain nothing by looping. |
Forum: Shell Scripting Jan 4th, 2007 |
| Replies: 2 Views: 3,624 script:
# $1 = path to examine
# usage
# myscript /path
find "$1" -type d -print |\
while read file
do
permissions=$(ls -l $file | awk '{print $1}') |
Forum: Shell Scripting Jan 4th, 2007 |
| Replies: 4 Views: 5,015 for i in vs01a vs01b
do
for k in 1 2
do
rsh $i echo $(tail -20 /opt/oracle/admin/+ASM/bdump/alert_+ASM"$k".log) >> VS_logs.txt
done
done
For "rsh" do you mean rexec or remsh? Or... |
Forum: Shell Scripting Dec 18th, 2006 |
| Replies: 1 Views: 5,453 su or sudo
Read the man page for su.
Both of these require superuser (root) access. |
Forum: Shell Scripting Dec 17th, 2006 |
| Replies: 1 Views: 2,068 The short answer is "yes". If you give an example of the data then we can help you. |
Forum: Shell Scripting Dec 14th, 2006 |
| Replies: 4 Views: 4,477 The way disk i/o in unix works is that data is parked in an in-memory cache in the kernel - it is not guaranteed to be written to disk when the write() system call is invoked. Every 30 seconds or... |
Forum: Shell Scripting Dec 13th, 2006 |
| Replies: 4 Views: 4,477 Record truncation? Not normal behavior unless the record has embedded ascii nul characters. Lack of disk space or exceeding enabled quotas will also cause the output file to truncate.
grep has a... |
Forum: Shell Scripting Dec 13th, 2006 |
| Replies: 4 Views: 3,756 file_name=`echo "$file_name" | sed 's/ //g'`
That removes any spaces in the file_name variable |
Forum: Shell Scripting Nov 30th, 2006 |
| Replies: 1 Views: 4,970 find does date comparisons for you.
Example - this code deletes files older than 48 hours (2 days):
find /home/julie/trash -type f -mtime +2 -exec rm -f {} \; |
Forum: Shell Scripting Nov 26th, 2006 |
| Replies: 1 Views: 1,775 myvar="Hi there"
backwards=`echo "$myvar" | rev`
echo "$backwards" |
Forum: Shell Scripting Nov 16th, 2006 |
| Replies: 2 Views: 3,661 One way
grep '^TDR ' Inputfile.log |
Forum: Shell Scripting Nov 6th, 2006 |
| Replies: 2 Views: 2,006 awk is what you want.
Assume your extract code runs like this: extract
and it prints data to stdout.
And assume you have columns of data and you want column #3 to be larger than 10.
... |
Forum: Shell Scripting Oct 26th, 2006 |
| Replies: 8 Views: 8,859 If you don't want the user to notice the script running:
nohup script.sh <parameters> 2>&1 > ./logfile &
As long as your script does not ask for user input this will work. Otherwise you... |
Forum: Shell Scripting Oct 24th, 2006 |
| Replies: 1 Views: 2,836 while read text
do
echo "$text" | sed 's#[|:;>]# #g' | read nm1 nm2 nm3 nm4
echo "$nm1 $nm2 $nm3 $nm4"
done < inputfile |
Forum: Shell Scripting Oct 24th, 2006 |
| Replies: 2 Views: 6,347 echo 'ftp://user:pass@host/path' | sed 's#[|:;>@/]# #g' | read dummy usr pwd hst pth
# or
echo 'ftp://user:pass@host/path' | tr -s '/' ' ' | tr -s ':' ' ' | tr -s '@' ' ' | read dummy usr pwd hst... |
Forum: Shell Scripting Oct 2nd, 2006 |
| Replies: 6 Views: 2,554 Since the homework deadline has gone by and somebody may search.
One simple way with sed
# using sed for wc -l
sed -n '$=' filename |
Forum: Shell Scripting Sep 29th, 2006 |
| Replies: 6 Views: 2,554 Another option: grep.
You have to show effort before we do your homework for you.
There is also a sed one hunk of code that does it as well.
You can also use a while ... do .. done loop. |
Forum: Shell Scripting Sep 21st, 2006 |
| Replies: 1 Views: 2,919 Since this is in Shell scripting:
pid=$$
$$ returns the pid of the current process (the one the shell is running in) |
Forum: Shell Scripting Sep 15th, 2006 |
| Replies: 2 Views: 1,808 This is actually an Oracle question:
dba_profiles sets the rules for the system, not how many login failures there are for a given user.
Offhand I do not know what SYS table Oracle currently uses... |
Forum: Shell Scripting Sep 15th, 2006 |
| Replies: 6 Views: 5,892 I changed it so awk puts it all on the same line. |
Forum: Shell Scripting Sep 12th, 2006 |
| Replies: 6 Views: 5,892 I'd use arrays:
#!/bin/ksh
optfile=filename
set -A opts $(awk 'BEGIN {FS="="} { if($0~ / page_size/) { print $2}}' $optfile)
for i in 0 1 2
do
echo ${opts[i]}
done |
Forum: Shell Scripting Sep 11th, 2006 |
| Replies: 9 Views: 7,043 #!/bin/bash
# we want to copy from path1 to path2
# step 1 make all the subdirectories
find /path1 -type d | \
while read dir
do
mkdir /path2"${dir#/path1}"
done
# step 2 cp the files... |
Forum: Shell Scripting Sep 11th, 2006 |
| Replies: 2 Views: 7,300 This checks $2 to see if ".kext" is anywhere in the $2 parameter
echo "$2" | grep -q '.kext'
if [[ $? -eq 0 ]] ; then
echo '.kext found'
else
echo '.kext not found'
fi |
Forum: Shell Scripting Sep 8th, 2006 |
| Replies: 4 Views: 1,729 In that case you have to use cp. mv does not mv over mount points. |
Forum: Shell Scripting Sep 8th, 2006 |
| Replies: 3 Views: 10,248 awk works for this pretty well -
awk '{
print $0
if($0=="Line2") {print "INSERTLINE2"}
if($0=="Line3") {print "INSERTLINE3"}
}' file > newfile |
Forum: Shell Scripting Sep 7th, 2006 |
| Replies: 5 Views: 6,432 Use
mailx -r '<from name>' -s '<subject here>' john@somewhere.com < message_text_file |
Forum: Shell Scripting Sep 6th, 2006 |
| Replies: 4 Views: 1,729 cd /to/my/directory
find . -name '*.jpg' | \
while read file
do
mv $file "new"$file
done
PS: mv works only within a filesystem. Even though you may be
in directories that are close in... |
Forum: Shell Scripting Aug 31st, 2006 |
| Replies: 9 Views: 13,376 find syntax is wrong there has to be a path
find PATH -name
In your case it looks like you should use a . (a dot ) which means the
current working directory. |
Forum: Shell Scripting Aug 30th, 2006 |
| Replies: 9 Views: 13,376 #!/bin/ksh
find /path/to/files -name 'tmp_*' | \
while read filename
do
tmpfile=${filename#tmp_}
mv "$filename" "emkt""$tmpfile"
done |
Forum: Shell Scripting Aug 15th, 2006 |
| Replies: 4 Views: 1,740 try an alias:
alias home="cd /home/budroeducom"
alias cd1="cd /some/longpath/to/somewhere"
typing
home
will execute |