Search this Website

 

Ubuntu

UNIX

grep command help

Category: UNIX-Unix Beginner

grep command help

hello, im trying to grep the first 3 lines(starting with error) from an output report and put it in a separate file... any help would be appreciated. below is the message contained in the report

error >invalid basic data (cmofct-5070)
cusip: 05950xal0 cmo#508039 tra# 11 rec# 175
firts int pay date: 1061110
bond type flag: v
floater type flag: 3
floater reset start date: 0
floater reset frequency: 0


Read More...

collecting & displaying of last user id and date of last log

Category: UNIX-Unix Beginner

collecting & displaying of last user id and date of last login

hi,

i needed to write a script to "collect and display the last user id and date of last login".

the requirement is:
when a workstation stops reporting it could be for many reasons. if we know the last person who logged in before the workstation came down, then we can contact the last person to login to that specific machine and ask them if they know what has happened to the workstation.

can someone provide a script to "collecting & displaying of last user id and date of last login".

thanks in advance,


Read More...

awksed one liner for text replacement

Category: UNIX-Unix Beginner

awk/sed one liner for text replacement

hi group,

i want to replace the occurance of a particular text in a paragraph.i tried with sed,but sed only displays the result on the screen.how can i update the changes in the original file???

the solution should be a one liner using awk and sed.


Read More...

triml leading zeros in unix

Category: UNIX-Unix Beginner

triml leading zeros in unix

hi all,

how does one trim leading zero's in unix

thanks


Read More...

how to display first 7 char of grep results

Category: UNIX-Unix Beginner

how to display first 7 char of grep results?

my file contains the following:

uat2000.aspclient.active=true
uat2001.aspclient.active=true
uat2002.aspclient.active=true
uat2003.aspclient.active=true
uat2004.aspclient.active=false
uat2005.aspclient.active=false
uat2006.aspclient.active=false
uat2007.aspclient.active=false
uat2008.aspclient.active=false
uat2009.aspclient.active=false

i am greping which ones = true with
# cat filename | grep active=true

results:

uat2000.aspclient.active=true
uat2001.aspclient.active=true
uat2002.aspclient.active=true
uat2003.aspclient.active=true

question: i want the results to display only the first 7 characters, ie uat2000, uat2001, etc - how do i do that?


Read More...

how to get rid of ^m from sql query

Category: UNIX-Unix Beginner

how to get rid of "^m" from sql query

i've searched the net and tried various solutions that don't work for me.

i'm trying to return values from a sql query and i keep getting a "^m" appended to one field.

code:

getting data from table

select * from table...
spooling to $home/out.log
...

wf_data=`tail -7 $home/out.log | awk '{print $1}'` assigning the values to wf_data variable

echo $wf_data > $home/out.log returning the data to out.log ... (may be dumb way but it works.. i need it for formatting purposes

wf=`tail -1 $home/out.log | awk '{print $1}'` #getting workflow
f=`tail -1 $home/out.log | awk '{print $2}'` #getting folder
s=`tail -1 $home/out.log | awk '{print $3}'` #getting server
u=`tail -1 $home/out.log | awk '{print $4}'` #getting user
p=`tail -1 $home/out.log | awk '{print $5}'` #getting pass

variable wf is having the "^m" appended to it.

any suggestions as to how to remove it?

(i tried sed -i '' "s/\r//g" $home/out.log (along with other variations) right after the sql statements and other sections - didn't work)


Read More...

at command does not work

Category: UNIX-Unix Beginner


Read More...

return value

Category: UNIX-Unix Beginner

return value

how do i find out the return value of a shell script or program in unix?

is there a command to find that out??


Read More...

make an account inactive after 90 days

Category: UNIX-Unix Beginner

make an account inactive after 90 days.

is this possible?

say i create an account today and in 90 days i want it to be turned off.

is this sort of thing possible using the built in components of a unix system?

(using solaris 9)

i see things about password expires, but what if the person changes his password on the 89th day, wouldn't that then set it again for another 90 days?


Read More...

determining type of file

Category: UNIX-Unix Beginner

determining type of file

hello,

i'm attempting to modify a script so it can be executed via a batch scheduler. part of the script calls a program called direct (which i believe may have something to do with connect direct). i have tried cat and vi on the file; cat returns absolute gibberish, vi states the file is executable.

i need to know the purpose of the program (it's inputs/outputs) and any parameters it requires. short of running it (it's on a live server) is there a way of finding out what type of program it is so i can view the code?

any help would be appreciated!


Read More...