Search Results

Showing results 1 to 40 of 41
Search took 0.01 seconds.
Search: Posts Made By: Salem ; Forum: Shell Scripting and child forums
Forum: Shell Scripting Aug 26th, 2009
Replies: 4
Views: 619
Posted By Salem
Use a different separator.
Eg.

sed -e "s@DATEST\@$DATESTART@g"

I can't figure out where the real separator is in the middle of the expression.
But you get the idea.
Forum: Shell Scripting Aug 25th, 2009
Replies: 4
Views: 619
Posted By Salem
sed -e "s/DATEST\/08/25/2009:07:41:41/g"
One or more of the / in your dates needs escaping.
Forum: Shell Scripting Jul 18th, 2009
Replies: 2
Views: 788
Posted By Salem
Step 1

MPUSED=`lsof | grep $MOUNT | awk '{print $2}' | sort -u`

This makes sure that each PID which might have open files is captured only once.

Step 2
Then do

for i in $MPUSED; do
Forum: Shell Scripting May 29th, 2009
Replies: 2
Views: 1,432
Posted By Salem
Use a while loop and the 'shift' method to process each argument in turn.

Use http://software.frodo.looijaard.name/getopt/
Forum: Shell Scripting May 13th, 2009
Replies: 8
Views: 826
Posted By Salem
So change the name in the find command.
Forum: Shell Scripting May 12th, 2009
Replies: 8
Views: 826
Posted By Salem
Well you could read the intro guides on how to post code, perhaps format the script so it's easier to read.

As opposed to one massive 1-liner which no-one wants to look at at all.
Forum: Shell Scripting May 9th, 2009
Replies: 2
Views: 549
Posted By Salem
Forum: Shell Scripting May 8th, 2009
Replies: 2
Views: 542
Posted By Salem
Piping works, if you can do this

open -e

/path/to/file

That is, if you just type in the "open -e", it gives you some kind of prompt for a filename.

If it doesn't do that, then piping...
Forum: Shell Scripting Feb 26th, 2009
Replies: 2
Views: 378
Posted By Salem
http://bashdb.sourceforge.net/bashdb-man.html
By convention, a -- option turns off all further option processing, and treats the rest of the command line as parameters.
Forum: Shell Scripting Jan 28th, 2009
Replies: 7
Solved: awk print total
Views: 2,135
Posted By Salem
The shell will allow you to create multi-line awk programs, which in this case would allow you to only read the file once, AND be sure that the $4 you see printed is the $4 being summed.

awk...
Forum: Shell Scripting Jan 27th, 2009
Replies: 7
Solved: awk print total
Views: 2,135
Posted By Salem
Strange, that would have worked - post your latest code.
Forum: Shell Scripting Jan 26th, 2009
Replies: 7
Solved: awk print total
Views: 2,135
Posted By Salem
I would have hoped after 40 posts that you would have figured this out.
Or at least read it.
http://www.daniweb.com/forums/announcement113-3.html
Forum: Shell Scripting Jan 20th, 2009
Replies: 4
Views: 1,481
Posted By Salem
Just put
ls
in there for now.

It's not magic, it's just a list of commands you want done every time you either login or create a new shell.
Forum: Shell Scripting Jan 20th, 2009
Replies: 4
Views: 1,481
Posted By Salem
Copy the example dot.bash_profile to your home directory as .bash_profile

Then start uncommenting the bits you would like, and adding any new things you would like.
Forum: Shell Scripting Jan 18th, 2009
Replies: 5
Views: 749
Posted By Salem
Yes, you're using tr wrongly.
tr just translates (or deletes) characters. Not lines, or things matching lines.

You could try
grep -v $remEmp $dataFile > temp
mv temp $dataFile

which finds...
Forum: Shell Scripting Jan 18th, 2009
Replies: 2
Views: 736
Posted By Salem
> sed -i 's/oldInfo/newInfo/g' "$dataFile"
You need to watch your shell's quoting rules.
Things in single quotes are preserved as is
Things in double quotes allow $substitutions.

Perhaps then...
Forum: Shell Scripting Jan 18th, 2009
Replies: 5
Views: 749
Posted By Salem
This is a partial list of GNU text utilities
http://www.rtr.com/win95pak/textutils.htm

Then there is
grep / egrep / fgrep - file searching
sed - simple file manipulation
awk - more complex...
Forum: Shell Scripting Jan 17th, 2009
Replies: 5
Views: 749
Posted By Salem
http://www.ss64.com/bash/gawk.html

Eg.

awk -v find="Fred" 'BEGIN{FS=","; RS="\n"}
$1 == find {printf "%s, %s, %s, %s\n", $1, $2, $3, $4}' data.txt


Just replace the green code...
Forum: Shell Scripting Dec 25th, 2008
Replies: 12
Views: 1,413
Posted By Salem
Nothing works by editing the file 'in place', even your vi editor.

It's all write the new file, delete the old file, then rename. It's just vi hides those steps from you. On very rare occasions...
Forum: Shell Scripting Dec 25th, 2008
Replies: 12
Views: 1,413
Posted By Salem
Do you want to delete it because it's line 2, or because it's green?

Read up on the sed command.

For example
sed '2d' file > newfile
or
sed '/green/d' file > newfile
Forum: Shell Scripting Dec 9th, 2008
Replies: 2
Views: 749
Posted By Salem
http://www.gnu.org/software/bash/manual/bashref.html#Arrays
Forum: Shell Scripting Dec 7th, 2008
Replies: 6
Views: 1,324
Posted By Salem
> awk '{print $rBytes / 100000}'END
How is that anything like what I posted?
Forum: Shell Scripting Dec 7th, 2008
Replies: 6
Views: 1,324
Posted By Salem
Personally, I would just do
awk '{print $2 / 1000000 }'

and stop worrying about just how good the maths is in the shell.

Also, awk has printf() as well, so you've got really good control over...
Forum: Shell Scripting Dec 3rd, 2008
Replies: 10
Views: 2,423
Posted By Salem
I'm confused.
Not all those lines contain "QuarkXP", but apparently, you passed the output of lsof through grep.
Forum: Shell Scripting Dec 3rd, 2008
Replies: 10
Views: 2,423
Posted By Salem
> lsof |grep QuarkXP|awk '{ print $9,$10,$11,$12 ]'>/tmp/output1
1. Copy the line you used, not something typed "as you remember it". The ] breaks it. I'm not sure your awk command to print a few...
Forum: Shell Scripting Oct 23rd, 2008
Replies: 10
Views: 2,580
Posted By Salem
Run mdadm in the forground, hence sequentially.
Run your progress in the background, then kill it when you're done.

And thanks for the explanations :icon_rolleyes:
Forum: Shell Scripting Oct 22nd, 2008
Replies: 10
Views: 2,580
Posted By Salem
If you ignore the "progress indicator" for the moment, does this actually work ?

# mdadm --manage /dev/md0 --add /dev/sdb1
# mdadm --manage /dev/md1 --add /dev/sdb2
# mdadm --manage /dev/md2...
Forum: Shell Scripting Oct 19th, 2008
Replies: 7
Views: 981
Posted By Salem
> I've already got rid of the tabs with the tr command so its a lot more cleaner now,
And destroyed any sense of where all the columns are with it no doubt.

If the result is variable width...
Forum: Shell Scripting Sep 23rd, 2008
Replies: 6
Views: 1,836
Posted By Salem
list in my example was a file, not a command.

> I want to loop through the dir to cat the last 21 lines of each file and put all the output to another file
for i in *; do tail -21 $i; done

...
Forum: Shell Scripting Sep 22nd, 2008
Replies: 6
Views: 1,836
Posted By Salem
First off, which "shell" are you talking about?
There are many varieties (sh, bash, ksh, csh) and syntax varies.

Maybe
for i in `cat list`; do tail -21 $i; done
Forum: Shell Scripting Jul 20th, 2008
Replies: 5
Views: 1,185
Posted By Salem
Try putting the filename variable in quotes in other places as well.
Forum: Shell Scripting Jul 9th, 2008
Replies: 5
Views: 1,086
Posted By Salem
Print what you want on separate lines, then use uniq ?
Forum: Shell Scripting Jul 9th, 2008
Replies: 5
Views: 1,086
Posted By Salem
uniq works on lines, not characters on the same line.
Forum: Shell Scripting Jul 8th, 2008
Replies: 2
Views: 1,027
Posted By Salem
> $result="$result $next"
Remove the first $ perhaps?
Like your other assignment earlier on.
Forum: Shell Scripting Jun 30th, 2008
Replies: 6
Views: 3,458
Posted By Salem
http://www.daniweb.com/forums/announcement113-2.html
Posting them is fine, so long as you show some effort.

You almost made it with
"# i tried, the output is a bit weird...."
but it would have...
Forum: Shell Scripting Jun 29th, 2008
Replies: 6
Views: 3,458
Posted By Salem
Smells like homework - where's your attempt at answers?
Forum: Shell Scripting May 30th, 2008
Replies: 4
Views: 2,339
Posted By Salem
Well what way(s) did you figure out so far, so we don't duplicate all the simple ones you know about so far.
Forum: Shell Scripting May 30th, 2008
Replies: 1
Views: 910
Posted By Salem
1. Look up the > and >> output redirection (and < input redirection)

2. Most ed command can be prefixed with a count, something like say 20s/target/
Forum: Shell Scripting May 29th, 2008
Replies: 2
Solved: csh vs sh
Views: 2,340
Posted By Salem
Avoid csh
http://www.faqs.org/faqs/unix-faq/shell/csh-whynot/
Forum: Shell Scripting May 22nd, 2008
Replies: 1
Views: 910
Posted By Salem
Perhaps
cp -r /home/henry/originalDir/* /home/henry/newDirectory

> by the way, what is the difference between cp and hard link?
A hard link isn't a copy of the file, but two directory entries...
Showing results 1 to 40 of 41

 


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

©2003 - 2009 DaniWeb® LLC