Search Results

Search: Posts Made By: 2pugs
2,533
Posted By 2pugs
Here's a quick perl script to do this trick. The...
Here's a quick perl script to do this trick. The idea is to store the contents of the file into an array. Then pop the end of the array until it reaches a none blank row.


#!/usr/bin/perl
my...
3,288
Posted By 2pugs
From the errors it gave you, it sounds like it's...
From the errors it gave you, it sounds like it's having trouble finding either the files or directories. I would verify that your path is correct. You could add a test for the directory in the...
3,288
Posted By 2pugs
Here's a ksh script that would do the trick. ...
Here's a ksh script that would do the trick.


#!/bin/ksh

for txtfile in $(ls $system/*.txt)
do
echo "# Filename: $txtfile"
cat $txtfile >> outputFileDirectoryName.txt
done
6,334
Posted By 2pugs
Yep. "file1", "file2" were all local to my...
Yep. "file1", "file2" were all local to my working directory. I'm a big fan of using full paths in my scripts so I would suggest it. I just wrote everything local to be just get the logic working....
6,334
Posted By 2pugs
This may not be the most efficient way if you're...
This may not be the most efficient way if you're files are really large but it works. Let me know if any of it is unclear.

Code:

#!/bin/bash
while read line
do
col1=$(echo $line | awk...
6,334
Posted By 2pugs
Are you matching row1 with row1, row2 with row2,...
Are you matching row1 with row1, row2 with row2, .. so on and so forth.. or can a match exist in any row?

Also are you trying to write this in a specific language or does it matter?
1,666
Posted By 2pugs
Hello, not sure what language you wanted it in. ...
Hello, not sure what language you wanted it in. Here's the ksh version.


#!/bin/ksh

n=0
while read line
do
a[$n]="$line"
n=$(expr $n + 1)
done < infile

n=0
while [ $n -lt...
7,011
Posted By 2pugs
My bet is it could be an environment issue. What...
My bet is it could be an environment issue. What shell are you in when you run it from the command line? Are you also specifying the shell at the top of your script? For example, if you were in...
9,419
Posted By 2pugs
Are you trying to match the first and last...
Are you trying to match the first and last character of each line? If so I fixed a few syntax errors you had and so I believe this should work for you now.


#!/bin/ksh

if [ $# -ne 1 ]
then...
Forum: Fedora 04-20-2011
32,097
Posted By 2pugs
We run Autosys here, but I'm sure it's not the...
We run Autosys here, but I'm sure it's not the conventional way. One daemon that might be in common is 'auto_remote'. Grep for this process and see if that is running.

If this is different,...
2,678
Posted By 2pugs
Try this: FILES_COUNT=$(find * -name "*"...
Try this:


FILES_COUNT=$(find * -name "*" | grep -v 'abc.txt' | wc -l)
4,352
Posted By 2pugs
Sure, but it's a little tricky. You would first...
Sure, but it's a little tricky. You would first need to find out the PID of the agent you started. You could do this with the 'ps' command.


% ps -ef | grep "run-any-agent MyProgramN " | grep...
4,352
Posted By 2pugs
This should do the trick. '$*' holds the...
This should do the trick. '$*' holds the positional parameters that you use when calling "run-all-agents". It executes and starts "run-any-agent" in the background.


#!/bin/bash

for agent in...
Forum: IP Networking 01-13-2010
14,413
Posted By 2pugs
I'm not familiar with the operating system of...
I'm not familiar with the operating system of Macs but I know they're unix based. I would use ifconfig -a to tell me what ip address it's configured to if I was on a unix or linux box.

Hope you...
2,664
Posted By 2pugs
It seems like with using '-e', you will need to...
It seems like with using '-e', you will need to write out [0-9] 8 times instead of using the shortcut '{8}'. Not sure why this is, but it worked for me.
2,552
Posted By 2pugs
I bow to the AWKers here. I have gotten by only...
I bow to the AWKers here. I have gotten by only using awk in it's simpliest form so I am continuously amazed at what it could do. My way would have been:


for num in `cat file1`
do
head...
2,664
Posted By 2pugs
It looks like you used '-e', but I just tried it...
It looks like you used '-e', but I just tried it with '-r' and I saw the change.
2,193
Posted By 2pugs
You could also use egrep to search for multiple...
You could also use egrep to search for multiple strings. Then test whether you found something or not.


egrep "CREATE|DROP" myfile.lst > /dev/null
if [ $? -eq 0 ]
then
mailx -s $MAIL_LIST <...
1,261
Posted By 2pugs
There is an egrep you can use. Try this: ...
There is an egrep you can use. Try this:


egrep -v "successfully completed|Total records: 0" my_logfile > new_file


This will remove the lines you didn't need and direct them to 'new_file'.
10,418
Posted By 2pugs
#!/bin/ksh while true #continuous loop...
#!/bin/ksh

while true #continuous loop (always true)
do
if [ -f /home/username/Desktop/A.txt ] # if file exists
then #execute these commands/script
/execute_this_script.ksh
...
5,365
Posted By 2pugs
sudo -l should list all the sudo commands that...
sudo -l should list all the sudo commands that you are able to run. This reads it from /etc/sudoers as mentioned above.
1,398
Posted By 2pugs
I would suggest creating a temp directory and...
I would suggest creating a temp directory and copying a few files there before running the script below. (Just to make sure it does what you need it to do)

#!/bin/ksh

cd your_directory

for...
24,564
Posted By 2pugs
$? should hold the value of whether it was...
$? should hold the value of whether it was successful. 0 = success, anything else = failed.

So immediately after your command, you can echo back $?.


cp file1 file2
if [ $? -eq 0 ]
then
...
1,702
Posted By 2pugs
Try creating a soft link from the old directory...
Try creating a soft link from the old directory to the new.
8,149
Posted By 2pugs
Have you tried testing what the value of $?...
Have you tried testing what the value of $? holds? Immediately after your print statement, you could add an if statement similar to this:


lp -onobanner -s -d$RPTDEST
if [ $? -eq 0 ] # If the...
Showing results 1 to 25 of 60

 
All times are GMT -4. The time now is 03:39 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy