Search Results

Search: Posts Made By: sanjaypraj
1,846
Posted By sanjaypraj
finding the common items can be done using two...
finding the common items can be done using two ways

fgrep -f file1 file2

or

awk 'NR==FNR{a[$1]=$1;next} a[$1]' file1 file2
2,561
Posted By sanjaypraj
yes, it can be done in similar way, use -v for...
yes, it can be done in similar way, use -v for every variables passed.
awk -F\| -v date=$v_date1 -v file=$filename 'NF==4{ print $0>date;next} NF!=4 {print $0 >file;next}' test1.txt
2,561
Posted By sanjaypraj
You need to send the value of the variable using...
You need to send the value of the variable using -v option to awk

awk -F\| -v date=$v_date1 'NF==4{ print $0>date;next} NF!=4 {print $0 >"murali.txt";next}' test1.txt
2,896
Posted By sanjaypraj
This may help ema=`echo "(${currentprice} *...
This may help

ema=`echo "(${currentprice} * 0.153846154) + (${previousema} * (1 - 0.153846154))" | bc`
1,532
Posted By sanjaypraj
Thanks methyl for the correction, i missed the...
Thanks methyl for the correction, i missed the top 10 part.
Just a change in your one liner


du -k apps | sed '$d' | sort -nr | head -10


-sk will give the total sum, sed to delete the total...
1,532
Posted By sanjaypraj
This may help using shell script. du -k apps...
This may help using shell script.

du -k apps > temp
sed '$d' temp > temp1
mv temp1 temp
awk '$1>max {max=$1;val=$2} END {print max, val}' temp
6,561
Posted By sanjaypraj
Please use backquote ` instead of single quote '...
Please use backquote ` instead of single quote ' at the code
Instead of

count='expr $count + 1'

It should be

count=`expr $count + 1`
1,548
Posted By sanjaypraj
If grep command is successful, it will set value...
If grep command is successful, it will set value of RC to 1, else it will set it to 0
4,540
Posted By sanjaypraj
Hi Raghunsi, Not an expert in sed and awk, but...
Hi Raghunsi,
Not an expert in sed and awk, but i have tried this using shell

#/usr/bin/ksh

while read var
do
echo "${var%%\<*}\n"
var1=`echo "<"${var#*\<}`
echo...
6,022
Posted By sanjaypraj
I am not sure if it can be done in a single unix...
I am not sure if it can be done in a single unix command, but this small script may help you

#!/usr/bin/ksh

for k in PMC*.arc
do
newfilename=`echo $k | sed 's/1//g'`
cp $k $newfilename...
15,171
Posted By sanjaypraj
Try this for last for loop should be for a...
Try this for last for loop should be

for a in 30 40 50 60 70 80
do
aa=${msat}a${a}
mkdir $aa
done


The $aa should be aa only
14,144
Posted By sanjaypraj
Hi Scottn, Thanks for reviewing my code and...
Hi Scottn,
Thanks for reviewing my code and finding the missing stuff, one of which probably because of a copy and paste error (`).
The reason for using

filename=`echo $k | cut -d ":" -f1`...
11,461
Posted By sanjaypraj
This may also help i believe ...
This may also help i believe
var="access.2Nov-12:15AM"
echo ${var%.*}
access
var1=`echo ${var%-*}`
echo ${var1#*.} | sed 's/\([0-9]*\).*/\1/'
2
echo ${var1#*.} | cut -c2-4
Nov
echo ${var#*-}...
17,999
Posted By sanjaypraj
Output it to some other file sed 's/\^J//g'...
Output it to some other file
sed 's/\^J//g' inputfile > outputfile
14,144
Posted By sanjaypraj
I am not sure if it can be done using some single...
I am not sure if it can be done using some single command. I have tried writing a small ksh shell script. Hope this will help.
#/bin/ksh
for k in `find ./ -type f| xargs grep oldstring
do
...
17,999
Posted By sanjaypraj
You can try sed 's/\^J//g' inputfile
You can try
sed 's/\^J//g' inputfile
2,037
Posted By sanjaypraj
Hope this may help #!/bin/ksh ...
Hope this may help


#!/bin/ksh
oldfilename=" "
while read line
do
filename=`echo $line | cut -c1-3`
if [[ "$oldfilename" = "$filename" ]]
then
echo $line >>$oldfilename
else...
2,576
Posted By sanjaypraj
Hi przemekny What kind of alert you are...
Hi przemekny
What kind of alert you are looking for. Is it sending through mail or at the prompt only.
8,568
Posted By sanjaypraj
This may help in getting the file size of all the files
sum=0
for k in `find . -mtime -730 -mtime +365 -exec ls -l {} \+ | awk '{print $5}'`
do
sum=$((sum+k))
done
echo "Total file size is $sum"
4
1,789
Posted By sanjaypraj
The "file" contains the existing data. sed...
The "file" contains the existing data.
sed '/^$/d' file > file1 // remove blank lines from the file
var=$(sed -n "`wc -l <file1`p" file1`) // to print the last line
echo ${var%*,} // remove...
5,829
Posted By sanjaypraj
sqlstmt1="update VAREntryTb set VAR10num =...
sqlstmt1="update VAREntryTb set VAR10num = VAR1num * Mltplr where BusD = '$val1' and RunI = 1"

Then put the variable sqlstmt1 in double quote

echo "$sqlstmt1"

the value of the variable varl1...
4,130
Posted By sanjaypraj
cat file | awk '{print $1}'
cat file | awk '{print $1}'
5,318
Posted By sanjaypraj
Try this script [[ -z $1 ]]&& echo "Argument...
Try this script

[[ -z $1 ]]&& echo "Argument needed "&& exit
[[ ! -s $1 ]]&& echo "File not found "&& exit
rm -f $1New
var=`wc -l <$1`
echo "Enter line no :\c"
read lineno
echo "Enter...
25,615
Posted By sanjaypraj
You can try this shell script rm -f fileout ...
You can try this shell script

rm -f fileout
i=1
while read line
do
if [[ $i -eq 1 ]]
then
echo $line >>fileout
i=0
continue
fi
if [[ $i -eq 0 ]]
then
...
10,914
Posted By sanjaypraj
Will a shell script do for you? I don't know if...
Will a shell script do for you? I don't know if it can be done using some command.
Showing results 1 to 25 of 26

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