Search Results

Search: Posts Made By: krishmaths
1,309
Posted By krishmaths
Use D in command mode. It deletes the rest of the...
Use D in command mode. It deletes the rest of the line from the cursor position.
Command C does the same but then switches to insert mode after deleting rest of the line so that you can start...
3,244
Posted By krishmaths
One solution using awk, without converting the...
One solution using awk, without converting the original input lines into intermediate format.

awk -F"_" '{++a[$1$3]} END{for(i in a){print i" "a[i]}}' input_file

Output:
hotbbb 2
coldbbb 1...
8,876
Posted By krishmaths
Not exactly. To explain further, following is the...
Not exactly. To explain further, following is the input data.

1,775,947,633
4,738
7,300
16,610
15,279
0
0

Expected output is (sum of all the numbers):
1775991560

I am trying to...
8,876
Posted By krishmaths
Sum up formatted numbers with comma separation
I need to sum up the values in field nr 5 in a data file that contains some file listing. The 5th field denotes the size of each file and following are some sample values.

1,775,947,633
4,738...
2,032
Posted By krishmaths
Or you may use negation in your original command...
Or you may use negation in your original command as follows:

awk '!NR%2{$0="some text "$0}1' file
1,617
Posted By krishmaths
grep -v "OK" is another option to exclude lines...
grep -v "OK" is another option to exclude lines with string "OK".

In your awk command, try printing entire line instead of just first field using just print or print $0
1,683
Posted By krishmaths
Thanks for your inputs. I tried the following and...
Thanks for your inputs. I tried the following and it worked. I needed to read from variable and not from a file.


RECORD="F1~F2~F3"
echo ${RECORD} | IFS="~" read VAR1 VAR2 VAR3
echo $VAR1 $VAR2...
1,683
Posted By krishmaths
I wanted to use specific variable names for...
I wanted to use specific variable names for better readability. For example, the actual field name is more readable than an array name with index. Hence did not go for array.

Another approach I...
1,683
Posted By krishmaths
Parsing fields into variables
A record contains 50 fields separated by "~". I need to assign each of these fields to different variables. Following is the shell script approach I tried.

...
851
Posted By krishmaths
Following code snippet would help. ...
Following code snippet would help.


DB=$(expr substr $1 1 1)
case $DB in
'B') DIR=/database/banking
;;
'R') DIR=/database/retailer
;;
*) echo error
;;
3,098
Posted By krishmaths
Permission to kill a process
I'm on AIX. I have triggered an infinite loop process (to keep looking for input file availability for further process). At present only I can kill the process.

In case my colleague wants to kill...
1,266
Posted By krishmaths
Are you on solaris? If so then try nawk
Are you on solaris? If so then try nawk
4,477
Posted By krishmaths
Just another way if [ $(echo $amt -...
Just another way


if [ $(echo $amt - $opn_amt | bc | grep ^-) ]; then
echo "correct"
else
echo "Wrong"
fi
1,231
Posted By krishmaths
Change your awk to awk...
Change your awk to

awk '{a[NR]=$3;b[NR]=$4;row[NR]=$0} END {for (i in a) printf("%s\t%.3f\n", row[i],(1-(b[i]/(7*24*60*a[i]))))}' infile
2,628
Posted By krishmaths
Or you can modify your awk statement to as below ...
Or you can modify your awk statement to as below

awk '{for(i=2;i<=NF;i++) {if (substr($i,1,1)=="#") next; else print $1,$i}}'
1,709
Posted By krishmaths
awk -F"," '{OFS=",";$++NF="unix"}1' file1 file2 ...
awk -F"," '{OFS=",";$++NF="unix"}1' file1 file2


or

awk '{print $0",unix"}' file1 file2
3,291
Posted By krishmaths
Could you paste the entire script? Ensure you...
Could you paste the entire script? Ensure you have the hashbang line at the beginning to denote the shell.. Example: #!/usr/bin/ksh

Save it as a script -> .ksh or .sh and execute it
3,291
Posted By krishmaths
Change only the directory name assigned to...
Change only the directory name assigned to variable DIR. Leave the remaining as is. substr should be on the line and hence $0 for awk to read the line.
1,238
Posted By krishmaths
@ Akshay, you are right. Good catch. But I'm not...
@ Akshay, you are right. Good catch. But I'm not sure if it is a valid scenario to have a variable like lck_

I presume the variable TABLE would vary and will be attached to lck_ as in


lck_T1...
3,291
Posted By krishmaths
DIR=/directory/with/2000/files for FILE in $(ls...
DIR=/directory/with/2000/files
for FILE in $(ls $DIR)
do
echo "insert into tabella ('"$(awk '{print substr($0,1,7)}' $DIR/$FILE)"','"$(cat $DIR/$FILE)"');"
done


Beware of ' appearing within...
2,400
Posted By krishmaths
Could the process id change between two...
Could the process id change between two statements?

Try using a file with fixed file name such as /tmp/hosts.tmp instead of /tmp/$$
3,291
Posted By krishmaths
Could you please add more details on your...
Could you please add more details on your statement
where the first column is a substring of the string of file.

What is the rule to fetch the substring? Is it first n characters or first 2...
1,238
Posted By krishmaths
Replace the if statement with if [ "$(echo...
Replace the if statement with

if [ "$(echo eval '$lck_'$TABLE)" != "" ]; then
9,824
Posted By krishmaths
sed substitution
sed 's/ | /,/g' infile
6,254
Posted By krishmaths
shell script
DIR=/your/directory
for FILE in $(ls $DIR)
do
OLD_DT=$(echo ${FILE##*_} | cut -d. -f 1)
NEW_DT=$(expr substr $OLD_DT 5 4)$(expr substr $OLD_DT 1 4)
RENAMED_FILE=$(echo...
Showing results 1 to 25 of 449

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