Search Results

Search: Posts Made By: chihung
3,225
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...
55,651
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,770
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...
3,020
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;
$,=" ";
...
Forum: Solaris 06-03-2012
3,412
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,298
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...
1,177
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...
3,337
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,708
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.


$...
2,088
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,607
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,...
1,649
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,778
Posted By chihung
vechicle="car" awk '/'$vehicle'/,/bicycle/'...
vechicle="car"
awk '/'$vehicle'/,/bicycle/' transportation.txt


Since you are using '/.../' , second way cannot be used.
2,770
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,353
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,485
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,671
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,877
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){...
18,467
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...
1,151
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
2,435
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...
3,764
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...
9,961
Posted By chihung
Try this (not tested): cd /test/testfiles ...
Try this (not tested):

cd /test/testfiles
for i in data*.unl.bz2
do
data_ymd=${i%%_*}
ymd=${data_ymd#data}
if [ ! -d $ymd ]; then
mkdir $ymd
fi
mv $i $ymd
done
5,076
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,894
Posted By chihung
awk '{$2=NR%2+1;print}' inputfile
awk '{$2=NR%2+1;print}' inputfile
Showing results 1 to 25 of 43

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