Search Results

Search: Posts Made By: guruprasadpr
7,821
Posted By guruprasadpr
One way: #!/bin/bash file1=$(date...
One way:


#!/bin/bash

file1=$(date '+%Y%m%d')
file2=$(date -d "1 day ago" '+%Y%m%d')
file1=$file1"_file.txt"
file2=$file2"_file.txt"
diff $file1 $file2
3,631
Posted By guruprasadpr
You are not passing any array, just a string is...
You are not passing any array, just a string is being passed and thats why the error.

Try like this:



test1(i,"A"i,"B"i+1);
split("hi:aa:ab",c,":");
...
1,839
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...
1,045
Posted By guruprasadpr
To make your aliases work inside shell script,...
To make your aliases work inside shell script, add a line like this in the beginning of your shell script:

source .bashrc #Assuming your shell is bash and rc file is .bashrc

Guru.
1,966
Posted By guruprasadpr
One reason could be, you need to escape the...
One reason could be, you need to escape the asterisk:

xyz=$(echo $ln/$val1\*100-100|bc -l|xargs printf "%1.0f\n")

Guru.
3,688
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,552
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.
1,045
Posted By guruprasadpr
rc file gets sourced whenever user gets into a...
rc file gets sourced whenever user gets into a sub-shell, and hence the aliases gets reflected in sub-shell. This is not the case for shell script. To get the aliases inside the shell script, you...
3,688
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,430
Posted By guruprasadpr
Assuming the space before the 2nd column in the...
Assuming the space before the 2nd column in the input file(line 1) is a typo:

awk -F, '{x=$4;$4-=a[$1$2];a[$1$2]=x;}1' OFS=, file

If not a typo, use this:
awk -F, '{gsub(/^...
3,768
Posted By guruprasadpr
If your grep is GNU, just grep is enough: To...
If your grep is GNU, just grep is enough:

To get the Head:
$ grep -oP '(?<=Head=")[^"]*' file
Test

To get the Title:
$ grep -oP '(?<=Title=")[^"]*' file
mode

Guru.
864
Posted By guruprasadpr
It's very hard to understand what you are exactly...
It's very hard to understand what you are exactly trying to ask. Can you please re-phrase your question better?

Guru.
1,108
Posted By guruprasadpr
Sort the files and compare: diff <(sort a)...
Sort the files and compare:

diff <(sort a) <(sort b)

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

Guru.
1,993
Posted By guruprasadpr
Like this: my $version =...
Like this:

my $version = "MYSQlcl-5.2.4-264.x86_64";
my @array1=$version=~/\d+/g;
my @array2 = (5,3,2,112);
my $ver1=join '',@array1[0..3];
my $ver2=join '',@array2;
if ($ver1 == $ver2){
...
875
Posted By guruprasadpr
It is actually checking whether the variabe...
It is actually checking whether the variabe _TABLESPACE_OFFLINE is empty or not.
4,542
Posted By guruprasadpr
If you are ok with a Perl solution: $ cat...
If you are ok with a Perl solution:

$ cat file
abc 10.122.53
10.122.53.5
efg 25.a23.33.44
12.176.254.24

Perl command:
$ perl -i -ple 'if...
1,217
Posted By guruprasadpr
One way: awk '/^[^>]/{printf...
One way:

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

Guru.
1,418
Posted By guruprasadpr
One way: find . -type d -exec du -s '{}' \; |...
One way:
find . -type d -exec du -s '{}' \; | awk '$1>100{print $2}'

@Pikk45:
Your solution is relying on the size shown by the ls -l output which actually is the block size for a directory....
3,291
Posted By guruprasadpr
sed -n 's/.*bhaski.\{4\}\(.*\)/\1/p' file ...
sed -n 's/.*bhaski.\{4\}\(.*\)/\1/p' file

Guru
3,593
Posted By guruprasadpr
sed is ideal for these kind of things: echo...
sed is ideal for these kind of things:

echo $line | sed 's/.*TYPE ="\([^"]*\)".*/\1/'

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

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

Guru.
1,373
Posted By guruprasadpr
Assuming your files are f1 and f2: To print...
Assuming your files are f1 and f2:

To print lines present in both the files:
comm -12 <(sort -u f1) <(sort -u f2)

To print lines present in f1, but not present in f2:
comm -23 <(sort -u f1)...
5,205
Posted By guruprasadpr
You can replace your whole code with one awk...
You can replace your whole code with one awk statement:

awk -F, 'NF>3{print "Error at line "NR;exit}' $TEMP_FILE

In place of 3, put the count of your no. of expected fields.

Guru.
18,555
Posted By guruprasadpr
sed -n '/SOURCE.* NAME /s/.* NAME...
sed -n '/SOURCE.* NAME /s/.* NAME ="\([^"]*_SRC\)".*/SOURCE->\1/p' file

Guru.
Showing results 1 to 25 of 500

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