Search Results

Search: Posts Made By: guruprasadpr
1,855
Posted By guruprasadpr
You cannot give the source file directly. Compile...
You cannot give the source file directly. Compile your C program and get an exe, and then execute the exe from the shell script.

Like:
Compile your C program:

$ cc -o myprog main.c
$ ls...
3,740
Posted By guruprasadpr
For zero padding in ksh, use the typeset command:...
For zero padding in ksh, use the typeset command:

$ typeset -RZ5 x
$ x=25
$ echo $x
00025

Mapping it to your case:
$ length=15
$ value="1234567890"
$ typeset -RZ${length} value
$ echo...
1,569
Posted By guruprasadpr
Like this since you are in Linux: $ cat file...
Like this since you are in Linux:

$ cat file
roses are red, so what do i do
nothing, just get the next string


$ var=$(grep -oP '(?<=roses )\S+' file)
$ echo $var
are

Guru.
3,740
Posted By guruprasadpr
You can do it like this: printf "%15s\n" ...
You can do it like this:

printf "%15s\n" "$value"


For dynamic:
printf "%*s\n" $length "$value"

Guru.
1,479
Posted By guruprasadpr
One way: sed 's/.*32=\([0-9]*\).*/\1/' file ...
One way:
sed 's/.*32=\([0-9]*\).*/\1/' file

Guru.
1,232
Posted By guruprasadpr
One way: awk '/^[^>]/{printf...
One way:

awk '/^[^>]/{printf $0;next}NR!=1{print "";}' file

Guru.
5,551
Posted By guruprasadpr
One way: awk '{sub(/CP/,"CP\n");}1' file ...
One way:

awk '{sub(/CP/,"CP\n");}1' file

Guru.
13,072
Posted By guruprasadpr
One way: $ awk '{print > $2"."$3"."$4".txt"...
One way:

$ awk '{print > $2"."$3"."$4".txt" }' file

After running the above awk command:
$ ls 1.10*
1.10.100.txt 1.10.1000.txt 1.10.101.txt

Guru.
3,054
Posted By guruprasadpr
Shell has property in which it expands anything...
Shell has property in which it expands anything given in braces:

$ echo AB{c,d}E
ABcE ABdE


So, its just a matter of replacing the square brackets with curly braces and putting comma between...
18,590
Posted By guruprasadpr
One way: $ sed -n '/SOURCE.* NAME /s/.* NAME...
One way:

$ sed -n '/SOURCE.* NAME /s/.* NAME ="\([^"]*\)".*/SOURCE->\1/p' file
SOURCE->ACTRL_BNFT_KEY_DMN

Guru.
1,242
Posted By guruprasadpr
Use NF-1 in-place of NF: awk...
Use NF-1 in-place of NF:

awk '/Gender/{g=$NF}/ID/{id=$NF}/[Hh]ire/{print id,g,$(NF-1)}' file

Guru.
25,230
Posted By guruprasadpr
Something like this: $ echo $x ="Lookup...
Something like this:

$ echo $x
="Lookup Procedure"

To remove = and " :
$ echo $x | sed 's/[="]//g'
Lookup Procedure

Guru.
1,227
Posted By guruprasadpr
One way: awk -F'!sil' '/!sil/{print $2}'...
One way:

awk -F'!sil' '/!sil/{print $2}' file

Guru.
4,023
Posted By guruprasadpr
awk 'NR==FNR{a[$1$3]=$0;next}{print a[$1$2],$3;}'...
awk 'NR==FNR{a[$1$3]=$0;next}{print a[$1$2],$3;}' file1 file2

Guru.
2,337
Posted By guruprasadpr
sed -i 's/\(var1=\).*/\11/' var -i To...
sed -i 's/\(var1=\).*/\11/' var

-i To update the file in-place
s - To find and replace (eg: s/find/replace/)
var1= - Finds the line containing the pattern var1= and it is grouped using...
2,337
Posted By guruprasadpr
The sed command provided updates your "var" file...
The sed command provided updates your "var" file with the value 1. This command does not give any output. You will see the changes next time when you source your file.

Guru.
5,581
Posted By guruprasadpr
Something like this: File 1: $ cat f1 ...
Something like this:

File 1:
$ cat f1
abc
def
ghi

Replacement content file:
$ cat f2
rep1
rep2


To replace the pattern 'def' in f1 with the file content of f2:

$ sed -e '/def/r...
2,653
Posted By guruprasadpr
Since your intention is just to have the temptime...
Since your intention is just to have the temptime and totaltime for individual SQL_FILE, you can use arrays instead: (Assuming you are using bash)

declare -A temptime totaltime
for...
1,889
Posted By guruprasadpr
One way: awk '!/^[0-9]/{x=$0;if(NR!=1)print...
One way:

awk '!/^[0-9]/{x=$0;if(NR!=1)print "";next}{print x,$0}' file
2,631
Posted By guruprasadpr
Hi Pipe your file listing output to this...
Hi

Pipe your file listing output to this command:

sort -t"-" -k2n,2
5,698
Posted By guruprasadpr
Hi awk '{x+=$9;}END{print "Total SGD "...
Hi


awk '{x+=$9;}END{print "Total SGD " x;}1' file

Guru.
5,252
Posted By guruprasadpr
Hi You should use it like this: my...
Hi
You should use it like this:

my ($req_user_info)=grep(/$x/,@input);

This is because grep returns a list, and when used in scalar context, you get the length.

Guru.
3,267
Posted By guruprasadpr
Hi mxlastupdate is a shell variable which...
Hi

mxlastupdate is a shell variable which you are trying to access in Perl directly which will not work.

export mxlastupdate
echo "Last Change in localtime is:" `perl -le 'print scalar...
1,513
Posted By guruprasadpr
Hi You are using the shell syntax of if. ...
Hi

You are using the shell syntax of if.

Perl syntax:
if ($diff == 1 ) {
.....
}else {
.......
}


Guru.
1,525
Posted By guruprasadpr
Hi $ awk...
Hi

$ awk '{a[++i]=$0;}/ERR-/{for(j=NR-x;j<=NR;j++)print a[j];}' x=1 file
some other text
ERR-12345
some blah blah blah
ERR-56789

You can specify your value of N against the x.

Guru.
Showing results 1 to 25 of 215

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