Search Results

Search: Posts Made By: kshji
1,153
Posted By kshji
You can make function to your .profile to...
You can make function to your .profile to overwrite external or builtin command, no need to setup PATH and create scriptfile.

Insert into .profile:

vi()
{
for f in $@
do
[ -s "$f"...
1,821
Posted By kshji
I'm not sure what all you need, but hopefully...
I'm not sure what all you need, but hopefully this examples give some ideas for your needs.

1st I made some example file. I hope that if you use some input files, you give those also. Much faster...
3,159
Posted By kshji
Alias works also in in noninteractive scripts. ...
Alias works also in in noninteractive scripts.

Make own rc-file if not like add this to default rc-file:

$HOME/.xxrc file:

alias nawk='echo No nawk'
for awk in /usr/bin/gawk...
1,539
Posted By kshji
Multiple file testing like rbatte1 tried to tell,...
Multiple file testing like rbatte1 tried to tell, if you need only know if some while include something.

found=0
for f in A*.rej
do
[ ! -s "$f" ] && continue
found=1
break
done
[...
5,726
Posted By kshji
Shortly: You have csv file which is something...
Shortly:
You have csv file which is something like:

00001,0012
...

And when you open in Excel by clicking your email attachment, the looks like:

1,12
...


It's Excel import default. I...
8,181
Posted By kshji
Using ksh93: #!/usr/bin/ksh # 2016-12-30...
Using ksh93:

#!/usr/bin/ksh
# 2016-12-30 16:20:11
LOG_TME="12302016162011"
NLOG_TME="${LOG_TME:4:4}-${LOG_TME:0:2}-${LOG_TME:2:2} ${LOG_TME:8:2}:${LOG_TME:10:2}:${LOG_TME:12:2}"
# or...
8,181
Posted By kshji
Ksh, bash, all posix-sh you can use builtin...
Ksh, bash, all posix-sh you can use builtin substr:

logmm=${NLOG_TME:0:2}
logdd=${NLOG_TME:2:2}
# ...
# no need echo, simply:
NLOG_TME="$logyy-$logmm-$logdd $logth:$logtm:$logts"
13,066
Posted By kshji
In this forum have been lot of questions parse...
In this forum have been lot of questions parse xml using awk.

I have published some solution (https://github.com/kshji/awk/tree/master/Xml) in one location. Sort toolset to parse xml using awk....
7,163
Posted By kshji
Here is example to calculate diff between login...
Here is example to calculate diff between login and session time ... easy to modify ..
using ksh93

#!/usr/bin/ksh
prev=""
name="someuser"

for logu in /tmp/$lognam/wtmp*
do
last -f...
7,163
Posted By kshji
Give example data which you have tried to parse.
Give example data which you have tried to parse.
6,022
Posted By kshji
Env problem ? Add line env >...
Env problem ?
Add line

env > /tmp/sapenv.tmp

to the script and run manually and via cron. Compare env.

Make your env file

cd /usr/sap/saprouter
env > myenv


Edit myenv if needed.
...
2,198
Posted By kshji
Maybe this example helps use to make comparing...
Maybe this example helps use to make comparing little easier in shell. You can add breaks as you like.

for file in *.txt
do
stat="DEPTH"
while IFS="," read f1 f2 DEPT SDEPT rest
do...
1,502
Posted By kshji
Works fine in posix shells: dash, ksh, zsh, bash,...
Works fine in posix shells: dash, ksh, zsh, bash, ...

# this solution no problem even input lines include some special chars, $IFS chars and so on.
while read file
do
first_line=$(head -1...
4,291
Posted By kshji
Have tested: # add to to the pipe : delete...
Have tested:

# add to to the pipe : delete spaces
# | tr -d " "
# and then make string comparing
while [ "$process_count" != 0 ]
1,697
Posted By kshji
ksh93 using builtin time conversion and...
ksh93 using builtin time conversion and calculation:

#!/usr/bin/ksh93

X1=02 ### Hour
Y1=20160405 ## Date
Z1=4 ## I want to Back 4 Hour

day=$(printf "%(%Y-%m-%d)T" $Y1)
timestamp="$day...
2,917
Posted By kshji
oifs="$IFS" while IFS="|" read county_code...
oifs="$IFS"
while IFS="|" read county_code county_name usr_nm passwd domain xstr
do
IFS="$oifs"
echo "Connecting to ${domain}"

$ORACLE_HOME/bin/sqlplus...
2,482
Posted By kshji
Here is two examples. Also read -p is usable. ...
Here is two examples. Also read -p is usable.

Using read -n 1.

#!/bin/ksh
# bash/ksh93/zsh/... but not dash (=posix)

# if read key ENTER, bash return newline and ksh return carriage return...
1,922
Posted By kshji
Most of syntax between ksh93...
Most of syntax between ksh93 (https://github.com/att/ast) and bash is same. All previous scripts works fine in bash (http://www.gnu.org/software/bash/manual/bashref.html) and ksh93.
Both support...
1,532
Posted By kshji
Look system cmd...
Look system cmd (http://php.net/manual/en/function.system.php), but http-server has not usually enough privileges to do ex. rm some user directory.

Need sudo...
1,348
Posted By kshji
awk ' BEGIN { FS=":" } ...
awk '
BEGIN {
FS=":"
}

{ # default for all lines
color="yellow"
}

$1 == "red" {
color=$1
}

{ # all lines
...
2,219
Posted By kshji
Example forever loop and if status is 0, then...
Example forever loop and if status is 0, then break the loop. Case is nice command to use string comparing.


#!/bin/bash
# or ksh
while true
do
# your db code here
# after that:...
8,588
Posted By kshji
Usually CGI need to return content type. And...
Usually CGI need to return content type. And using HERE method it's easier to write web page with variable and command expand. Rest is html/javascript problem, not scripting.


#!/bin/bash
cat...
1,818
Posted By kshji
for i in server1* do [ "$i" =...
for i in server1*
do
[ "$i" = "server1*" ] && continue # there wasn't any files
# remove echo if looks good
echo mv "$i" "${i/server1/server2}"
done
1,925
Posted By kshji
Please: give the full if - then fi block. Easier...
Please: give the full if - then fi block. Easier to say.
8,358
Posted By kshji
If you need really put something to do in...
If you need really put something to do in background, then do something (parallel) and after that wait the child process to end, solution could be something like:


child()
{
parentfile=$1

...
Showing results 1 to 25 of 500

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