Friday, August 11, 2023

wget usage

To download multiple files from  web ;

 wget -r -nd --no-parent "http://foo.com" -A "*.jpg"


Friday, August 4, 2023

Print a character while command is executing in Linux

function printChar

{

    local pid=$!

    local delay=0.50

    local spinstr='...'

    echo "Loading "

    while [ "$(ps a | awk '{print $1}' | grep $pid)" ]; do

        local temp=${spinstr#?}

        printf "%s  " "$spinstr"

        local spinstr=$temp${spinstr%"$temp"}

        sleep $delay

        printf "\b\b\b"

    done

    printf "    \b\b\b\b"

echo

}

####

sqlplus -S $ouser/$opass@$oserver @$tmpPth/qry.sql & printChar



Thursday, February 2, 2023

Deleting crlf and concat lines in Linux

 for dosya in 2023*/*.tem ; do echo $dosya ; cat $dosya|sed ':a;N;$!ba;s/\n//g' >> test ; done

Wednesday, February 1, 2023

Finding files that consist empty lines and concat

grep  -l ^$ filename | xargs -i cp {} tmp1/        # find files if file consist empty line(s)

for fname in tmp1/aero* ; do echo $fname ; purefile=`echo $fname|awk -F "/" '{print $2}'`; cat $fname |awk '{print}' ORS=' ' > tmp2/$purefile ; done        # deletes empty line and copies to another directory

Wednesday, November 9, 2022

Find Disk Write Performance; 

dd if=/dev/zero of=/tmp/output bs=16k count=10k  >> /root/diskwrite.txt  (runs in a crontab)

After a while;

cat diskwrite.txt |grep bytes|awk -F "," '{print $4}'|awk '{print $1}'|awk '{top=top+$NF; print top/NR}'


Tuesday, July 5, 2022

 Oracle Turkish Character Support;

echo "

set echo off

set verify off

set termout off

set trimout on

set heading off

set feedback off

set colsep ';'

set pagesize 0

set trimspool on

set headsep off

set linesize 5000

set serveroutput off

spool $tmpdir/${fname1}.txt

alter session set nls_language='TURKISH';

SELECT AIRPORT, a.ISTNO,${perbas}||'-'||${person},sum(VALUE) from TABLE1 a, TABLE2 where a.ICAO=b.ICAO and b.SENSOR_NAME IN('RAININST','PR_INS','RAIN_TDZ2','RAIN_TDZ1') and SENSOR_TIME between to_date('$perbas','YYYYMMDDHH24Mi') and to_date('$person','YYYYMMDDHH24Mi') group by AIRPORT,a.ISTNO order by 2 ;

spool off

exit " > $sql

sqlplus -S $ouser/$opass@$oserver @$sql

Change Spesific Columns Value According to a condition


This changes 4th columns value to "none" if it is zero.

awk 'BEGIN{FS=OFS=";"} $4 == "0" ;{$4 = "none"; } {print $0}' $filename