Search Results

Search: Posts Made By: chihung
1,829
Posted By chihung
In Solaris, /usr/bin/grep does not support -q...
In Solaris, /usr/bin/grep does not support -q flag. Try to use /usr/xpg4/bin/grep, see man page for details.

You need to test the return status ($?) for the /usr/xpg4/bin/grep 'cos it does not...
Forum: Solaris 06-03-2012
3,531
Posted By chihung
'seq' does not exist in Solaris. This url...
'seq' does not exist in Solaris.

This url may help. Chi Hung Chan: ZFS on 48 Disks without X4500 (http://chihungchan.blogspot.sg/2007/03/zfs-on-48-disks-without-x4500.html)
4,410
Posted By chihung
If you are using Linux, you can grep --color...
If you are using Linux, you can grep --color successfully /variosnew/fullexports/IMAGES/full_imp_images.log

For more colors, pls refer to Chi Hung Chan: Give Your Shell Some Colours...
3,353
Posted By chihung
It will be hard for anyone to help you with this...
It will be hard for anyone to help you with this long script. What I can propose to you is to run it with "bash -x yourscript" to get the shell to print out the commands while it is executing.

You...
3,405
Posted By chihung
Assuming that your 'link' tag is in two lines ...
Assuming that your 'link' tag is in two lines

awk '
/^<link rel="alternate" type="application\/rss\+xml"/ || /^<link rel="alternate" type="text\/x-opml"/ {
getline
next
}
{
...
2,758
Posted By chihung
Hi Scrutinizer, I don't think your proposed...
Hi Scrutinizer,

I don't think your proposed redirection will work "$s1.txt" will be interpreted by shell before doing the read and this will just resulted in ".txt". Here is my little test.


$...
55,780
Posted By chihung
To exactly retrieve the value from an XML file,...
To exactly retrieve the value from an XML file, you need to use an XML tool such as xmllint. It comes with Linux by default.

$ version=`xmllint --xpath...
1,219
Posted By chihung
What you can do is to use Firefox's Live HTTP...
What you can do is to use Firefox's Live HTTP Headers (https://addons.mozilla.org/en-US/firefox/addon/live-http-headers/) to capture a typical user login session. With that, you can loop through all...
2,105
Posted By chihung
you can use 'file' to find out. read the man page...
you can use 'file' to find out. read the man page file(1) and magic(5) for more

$ file ace.png
ace.png: PNG image data, 725 x 111, 8-bit/color RGB, non-interlaced

$ mv ace.png ace.tla

$...
1,678
Posted By chihung
vehicle1=car vehicle2=bicycle nawk -v...
vehicle1=car
vehicle2=bicycle
nawk -v v1="$vehicle1" -v v2="$vehicle2" 'match($0,v1),match($0,v2)' transportation.txt
3,803
Posted By chihung
vechicle="car" awk '/'$vehicle'/,/bicycle/'...
vechicle="car"
awk '/'$vehicle'/,/bicycle/' transportation.txt


Since you are using '/.../' , second way cannot be used.
1,647
Posted By chihung
Try this: #! /bin/sh if [ $# -ne 1 ];...
Try this:

#! /bin/sh

if [ $# -ne 1 ]; then
echo "Usage: $0 <uid>"
exit 1
fi

awk -v uid=$1 '
NF==2 && $1~/^conn=/ && $2~/^uid=/ {
split($1, a, "=")
split($2,...
3,117
Posted By chihung
Install perl XML::XPath module # yum install...
Install perl XML::XPath module

# yum install perl-XML-XPath.noarch
or
# perl -MCPAN -e 'install XML::XPath'


Try this:

#! /usr/bin/perl
use XML::XPath;
$,=" ";
...
2,825
Posted By chihung
You may want to refer to my blog Chi Hung Chan:...
You may want to refer to my blog
Chi Hung Chan: Highlight Those Files With Space, Backslash or Non-Printable Characters...
2,403
Posted By chihung
put the original folder together with the dir...
put the original folder together with the dir name together and sort base on the 2nd field.


sep="|"
while read d
do
# get rid of the trailing /
dd=${d%/}

# print the orginal and...
3,525
Posted By chihung
This list provides index to the abbr month name....
This list provides index to the abbr month name. The 4th column returns from the 'localtime' will give the index of the month. Eg. 2 means Mar. List index starts from 0
...
3,733
Posted By chihung
#!/usr/bin/ksh echo "Enter 10 numbers" for...
#!/usr/bin/ksh

echo "Enter 10 numbers"
for i in 1 2 3 4 5 6 7 8 9 10
do
read a
echo $a
done > numbers
1,906
Posted By chihung
What you can do is to remove the leading zero...
What you can do is to remove the leading zero before you feed into awk. Try this

set -- `date '+%b %d'`
mth=$1
day=${2#0}
awk -v d="$mth$day" '/user:warn/ && /has shutdown/ && ($1$2 == d){...
2,463
Posted By chihung
Try this by escape the forward slash and use...
Try this by escape the forward slash and use double quote in awk:

TODAY=$(perl -e '@now=localtime; printf "%02d\\/%02d\\/%02d", $now[4]+1,$now[3],($now[5]+1900)%100')

YESTERDAY=$(perl -e...
18,629
Posted By chihung
If you are doing this within a loop, you may want...
If you are doing this within a loop, you may want to consider using the built-in feature of bash/ksh parameter expansion. This will save you 1 exec for every loop

v="abc/def/ghi/jkl/mn.txt"
echo...
3,819
Posted By chihung
One-liners are to impress people the power of...
One-liners are to impress people the power of UNIX.

Let me try to break them down into multi-line with comments so that you can appreciate the real power

awk '
# for every odd record number...
1,159
Posted By chihung
case $x in *$a*) echo a ;; *$b*) ...
case $x in
*$a*)
echo a
;;
*$b*)
echo b
;;
*$c*)
echo c
;;
*)
echo default
;;
esac
5,155
Posted By chihung
find yourdirectory -type f -ls 2>/dev/null | ...
find yourdirectory -type f -ls 2>/dev/null |
while read x x x x x x s x x x f
do
if [ $s -eq 0 ]; then
rm -f "$f"
fi
done
3,940
Posted By chihung
awk '{$2=NR%2+1;print}' inputfile
awk '{$2=NR%2+1;print}' inputfile
3,438
Posted By chihung
Simply cut and paste the python code into a file...
Simply cut and paste the python code into a file and chmod 755 on that. Just like other shell scripts
Showing results 1 to 25 of 43

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