Visit Our UNIX and Linux User Community

Search Results

Search: Posts Made By: kshji
1,014
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
[...
1,541
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,021
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,095
Posted By kshji
awk ' BEGIN { FS=":" } ...
awk '
BEGIN {
FS=":"
}

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

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

{ # all lines
...
1,782
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:...
1,637
Posted By kshji
Here is pure bash...
Here is pure bash (ftp://ftp.gnu.org/pub/gnu/bash/)/ksh93 (https://github.com/att/ast) solution. Not used any external commands like awk, perl, grep, sed, ...

If you have too old bash, update it....
817
Posted By kshji
Here is example to use ksh93...
Here is example to use ksh93 (http://www2.research.att.com/~astopen/cgi-bin/download.cgi?action=list&name=ksh) shell, which include builtin date calculation properties.

In other shell you can use...
3,470
Posted By kshji
After started bg process, save child process...
After started bg process, save child process process id (variable !).


db2 "Call PROC1" &
pid1=$!

db2 "Call PROC2" &
pid2=$!

db2 "Call PROC3" &
pid3=$!


# then only wait that every...
3,781
Posted By kshji
You trying HERE input ? syntax is cmdline...
You trying HERE input ?
syntax is

cmdline <<EndOfInputString
data
EndOfInputString

# ex.
cmdline <<EOF
data
EOF
1,355
Posted By kshji
Publishing more code maybe give us more...
Publishing more code maybe give us more understanding.

Both rule works if input is as you have written.

# awk rule using default FS
$1 == "Swap:" { # do something
}
# or...
1,752
Posted By kshji
This give the number of csv files in current...
This give the number of csv files in current directory tree.

count=$( find . -type f -name "*.csv" | wc -l )
echo $count
1,756
Posted By kshji
You can test also empty string without X...
You can test also empty string without X extension - this example is cut&pasted worldwide, but sh shells don't need it. You can test simple

if [ "$FILE_SIZE" = "" ] ; then # value is empty
...
1,731
Posted By kshji
Awk is awk, it has own syntax. Something same as...
Awk is awk, it has own syntax. Something same as in C, but lot of own, whole rule for block idea is something different.

Shell is shell and it has own syntax.

Awk is not part of shell. It's own...
1,337
Posted By kshji
Bash and ksh93 you can use (( )). if ((...
Bash and ksh93 you can use (( )).

if (( ex_year >= curr_year && ex_month >= curr_month && ex_day <= curr_day ))
then
condition...
fi


This work in every sh, dash,...
1,154
Posted By kshji
If you have not eXcute priviledge in the script...
If you have not eXcute priviledge in the script file, then you need start the interpreter like sh and input is readed from file (arg 1).

If your input file not include needed interpreter then...
2,094
Posted By kshji
FreeTDS (http://www.freetds.org/) Download...
FreeTDS (http://www.freetds.org/)

Download FreeTDS (http://mirrors.ibiblio.org/freetds/stable/)

Using tsql, bsqldb, freebcp

TDSVER=4.7
tsql -H sqlserverIP -p 1433 -U username -P password...
853
Posted By kshji
In the shell scripts if is also command. Looks...
In the shell scripts if is also command. Looks like if in the programming languages but it's not same.
After if is some command, example test or shortly [ or compound command [[ or even cp or ...
...
7,581
Posted By kshji
xargs is nice command when you need to give some...
xargs is nice command when you need to give some output to the next command arguments

some_command_output | xargs kill

Example kill apache processes

ps -ef | grep apache | grep -v grep | awk...
2,146
Posted By kshji
Add redirect , then cron not send email. * *...
Add redirect , then cron not send email.

* * * * * /some/command >/dev/null 2>&1
2,677
Posted By kshji
You can do solution using select PS3="Your...
You can do solution using select

PS3="Your choice (ENTER=list again, e=end):"
select f in *.zip
do
[ "$REPLY" = "e" ] && break
echo "Choice: ($REPLY) $f"
echo $f
...
2,585
Posted By kshji
Here are two solution, using pure ksh/bash or...
Here are two solution, using pure ksh/bash or awk, not mixed.

#!/usr/bin/someposixshell ksh, bash, dash, ...

# make tmp file for input
cat <<EOF > $0.tmp
Name : sdt2156157_ID
NOS : 4567 [...
1,450
Posted By kshji
awk ' /^A/ { begin=$0 } # line start A ...
awk '
/^A/ { begin=$0 } # line start A
/^B/ { print begin $0 } # line start B
' inputfile
26,090
Posted By kshji
Something like this: echo -n "number:" ...
Something like this:

echo -n "number:"
read res
PS3="select operation (ENTER=menu again, e=end):"
select f in add sub div mul
do
[ "$REPLY" = "e" ] && break
echo -n "number:"...
1,519
Posted By kshji
After if it's always command in shells: [, [[, ((...
After if it's always command in shells: [, [[, (( are only some commands.

if commandline
then # exit status 0
:
else # exit status != 0
:
fi

[ and test are same command, usually...
1,519
Posted By kshji
Return is exit from function. Not for return...
Return is exit from function. Not for return values. Stdout is method to return values.
$? = last command exit status, 0=ok, <>0 not so ok.

pattern()
{
val1=$1
val2=$2
(( val1 == 100...
Showing results 1 to 25 of 57

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