- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Share your one liner scripts
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2004 09:16 PM
05-25-2004 09:16 PM
Share your one liner scripts
Perl, sh, ksh, csh, etc....
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2004 09:27 PM
05-25-2004 09:27 PM
Re: Share your one liner scripts
Mirror a set of logical volumes to a single mirror disk:
vgdisplay -v /dev/vgxx | grep "LV Name" | awk '{print $3}'|while read v;do;lvextend -m 1 $v /dev/dsk/cxtxdx;done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2004 10:40 PM
05-25-2004 10:40 PM
Re: Share your one liner scripts
Check this link:
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=51050
Regards,
Gideon
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2004 11:33 PM
05-25-2004 11:33 PM
Re: Share your one liner scripts
ps -ef | cut -c42-80 | sort -nr | head
Create a list of files not created in May (substitute as needed) to remove from a given directory:
ll | grep -v " May " | awk '{print "rm ",$NF)' > useme
Then execute the file "useme".
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2004 01:40 AM
05-26-2004 01:40 AM
Re: Share your one liner scripts
echo \$Z | /usr/sbin/sendmail -bt -d
Identify and display stale extends on all system volume groups:
vgdisplay -v | awk '/LV Name/ { print $3 }' | xargs lvdisplay -v | grep -i -e "lv name" -e "lv status" -e stale -e '?'
Rgds...Geoff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2004 01:51 AM
05-26-2004 01:51 AM
Re: Share your one liner scripts
cat license.log|perl -ne 's/\(tring-to-purge\)//;if ($_ =~ /TIMESTAMP (.*)/) { $ts=$1;} else { /license_name/ && print "$t $_";} '|less
Peace, R>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2004 02:59 AM
05-26-2004 02:59 AM
Re: Share your one liner scripts
UNIX95= ps -eo vsz,ruser,pid,args |sort -rn | head -10
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2004 03:29 AM
05-26-2004 03:29 AM
Re: Share your one liner scripts
ps -ef | grep username | grep -v grep | awk {'print $2'} | xargs kill
(optional -9 to kill command on second attempt)
UNIX because I majored in cryptology...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2004 05:14 AM
05-26-2004 05:14 AM
Re: Share your one liner scripts
kill -9 $(ps -aex | grep mozilla | grep -v grep | awk '{print $1}')
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2004 07:48 AM
05-26-2004 07:48 AM
Re: Share your one liner scripts
will list all of the processes started in the last 24 hours that are still running. This comes in handy in identifying stuck processes, before the user calls and complains.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2004 08:49 AM
05-26-2004 08:49 AM
Re: Share your one liner scripts
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2004 09:02 AM
05-26-2004 09:02 AM
Re: Share your one liner scripts
in csh source file.sh
in ksh . file.sh (dot space file)
Frank.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2004 09:43 AM
05-26-2004 09:43 AM
Re: Share your one liner scripts
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2004 09:54 AM
05-26-2004 09:54 AM
Re: Share your one liner scripts
$ cat /var/adm/sulog | awk '$4 == "-" {print $0}' | grep 'root$'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2004 02:30 PM
05-26-2004 02:30 PM
Re: Share your one liner scripts
Here are some better solutions:
ps -ef | grep username | grep -v grep | awk {'print $2'} | xargs kill
is much more accurate when written:
ps -f -u username | awk '{print $1}' | xargs kill
The first script could be VERY dangerous because grep doesn't care what it matches. If the username is ash, then the first form kills all copies of bash (every user) as well as the unhasdaemon (not good!) and so on. The second form only returns processes used by a specific (and exact match) username.
And the other example will kill every process owned by mozilla9 as well as the mozilla process. Rather than:
kill -9 $(ps -aex | grep mozilla | grep -v grep | awk '{print $1}')
Use this:
kill $(UNIX95= ps -C mozilla -o pid | grep -v PID)
In this case, grep gets rid of the column title line PID and leaves zero or more process ID numbers. ps looks at the exact process name, so -C sh will not match bash or ksh.
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-27-2004 04:34 AM
05-27-2004 04:34 AM
Re: Share your one liner scripts
You can run an actual csh to ask it to report the current environment that .cshrc will setup.
This one-liner puts the csh environment into a sh script that it sources into the current sh.
csh -c env | sed "s/^/export /;s/=/='/;s/$/'/" > .csh_env; . .csh_env
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-27-2004 04:38 AM
05-27-2004 04:38 AM
Re: Share your one liner scripts
You don't need to grep away the PID header.
You can use "pid=" to ask ps to not print any header.
(Mozilla is usually seen as mozilla-bin.)
kill $(UNIX95= ps -C mozilla-bin -o pid=)
What do people have against lizards anyway?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-27-2004 05:49 AM
05-27-2004 05:49 AM
Re: Share your one liner scripts
# replace PAT1 with PAT2 in file
perl -p -e 's/PAT1/PAT2/' file
# replace PAT1 with PAT2 in file and make original file.bak
perl -pi.bak -e 's/PAT1/PAT2/' file
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-27-2004 06:01 AM
05-27-2004 06:01 AM
Re: Share your one liner scripts
perl -pi -e 's?PAT1/PAT2/ file
without the i it just goes to STDOUT
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-27-2004 08:48 AM
05-27-2004 08:48 AM
Re: Share your one liner scripts
ll /dev/*/group | sort -b -k6,6
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-27-2004 09:03 AM
05-27-2004 09:03 AM
Re: Share your one liner scripts
fuser /var/adm/syslog/syslog.log 2>/dev/null | xargs -n1 ps -fp
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-27-2004 09:31 AM
05-27-2004 09:31 AM
Re: Share your one liner scripts
nice find / -perm -o+w -exec ls -l {} \; -exec chmod o-w {} \; | tee -a /tmp/wwf.out
Note, performing a find from the root (/) level can take awhile and chew up resources ... so, I use nice to share the system processor resources.
Also, dumping the output to a file so that we can go back and determine the ownership and locations of the files and talk with the file owner and provide him/her with a security dissertation.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-27-2004 01:34 PM
05-27-2004 01:34 PM
Re: Share your one liner scripts
Pls. note that this was out of Tru64/AIX, you may need to adjust the field positions to filter the HP-UX's bdf output.
df -k | sort -r -k 5 |egrep -v "exclude1|exclude2|exclude3|..|.." |awk 'split($4,a,"%") && a[1] > 75 {print $7, $4}'