Search Results

Search: Posts Made By: guruprasadpr
9,409
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
4,006
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,":");
...
2,196
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,266
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.
2,330
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.
4,393
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,790
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,266
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...
4,393
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,675
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,935
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.
973
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,209
Posted By guruprasadpr
Sort the files and compare: diff <(sort a)...
Sort the files and compare:

diff <(sort a) <(sort b)

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

Guru.
2,435
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){
...
1,081
Posted By guruprasadpr
It is actually checking whether the variabe...
It is actually checking whether the variabe _TABLESPACE_OFFLINE is empty or not.
4,776
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,352
Posted By guruprasadpr
One way: awk '/^[^>]/{printf...
One way:

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

Guru.
1,706
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,511
Posted By guruprasadpr
sed -n 's/.*bhaski.\{4\}\(.*\)/\1/p' file ...
sed -n 's/.*bhaski.\{4\}\(.*\)/\1/p' file

Guru
4,466
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.
6,091
Posted By guruprasadpr
One way: awk '{sub(/CP/,"CP\n");}1' file ...
One way:

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

Guru.
1,543
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,685
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.
19,199
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 04:20 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy