Unix/Linux Go Back    

Showing results 1 to 25 of 500
Search took 0.08 seconds.
Search: Posts Made By: guruprasadpr
Forum: Shell Programming and Scripting Linux 12-01-2014
Replies: 4
Views: 1,602
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
Forum: Shell Programming and Scripting Linux 09-16-2013
Replies: 10
Views: 1,186
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,":");
...
Forum: Shell Programming and Scripting Linux 04-24-2013
Replies: 3
Views: 1,114
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...
Forum: Shell Programming and Scripting Linux 04-17-2013
Replies: 5
Views: 529
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.
Forum: Shell Programming and Scripting Linux 04-17-2013
Replies: 4
Views: 846
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.
Forum: Shell Programming and Scripting Linux 04-17-2013
Replies: 19
Views: 1,241
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"
Forum: Shell Programming and Scripting Linux 04-17-2013
Replies: 4
Views: 769
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
Forum: Shell Programming and Scripting Linux 04-17-2013
Replies: 5
Views: 529
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...
Forum: Shell Programming and Scripting Linux 04-17-2013
Replies: 19
Views: 1,241
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.
Forum: Shell Programming and Scripting Linux 04-17-2013
Replies: 5
Views: 804
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(/^...
Forum: Shell Programming and Scripting Linux 04-17-2013
Replies: 3
Views: 2,026
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
Forum: Shell Programming and Scripting Linux 04-17-2013
Replies: 3
Views: 482
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.
Forum: Shell Programming and Scripting Linux 04-12-2013
Replies: 3
Views: 703
Posted By guruprasadpr
Sort the files and compare: diff <(sort a)...

Sort the files and compare:

diff <(sort a) <(sort b)

Guru.
Forum: Shell Programming and Scripting Linux 04-12-2013
Replies: 2
Views: 829
Posted By guruprasadpr
One way: sed 's/.*32=\([0-9]*\).*/\1/' file ...

One way:
sed 's/.*32=\([0-9]*\).*/\1/' file

Guru.
Forum: Shell Programming and Scripting Linux 04-12-2013
Replies: 1
Views: 770
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){
...
Forum: Shell Programming and Scripting Linux 04-10-2013
Replies: 1
Views: 399
Posted By guruprasadpr
It is actually checking whether the variabe...

It is actually checking whether the variabe _TABLESPACE_OFFLINE is empty or not.
Forum: Shell Programming and Scripting Linux 04-10-2013
Replies: 3
Views: 2,449
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...
Forum: Shell Programming and Scripting Linux 04-05-2013
Replies: 3
Views: 708
Posted By guruprasadpr
One way: awk '/^[^>]/{printf...

One way:

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

Guru.
Forum: Shell Programming and Scripting Linux 04-05-2013
Replies: 3
Views: 683
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....
Forum: Shell Programming and Scripting Linux 04-05-2013
Replies: 2
Views: 1,434
Posted By guruprasadpr
sed -n 's/.*bhaski.\{4\}\(.*\)/\1/p' file ...

sed -n 's/.*bhaski.\{4\}\(.*\)/\1/p' file

Guru
Forum: Shell Programming and Scripting Linux 04-04-2013
Replies: 4
Views: 889
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.
Forum: UNIX for Dummies Questions & Answers Linux 04-04-2013
Replies: 5
Views: 1,527
Posted By guruprasadpr
One way: awk '{sub(/CP/,"CP\n");}1' file ...

One way:

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

Guru.
Forum: Shell Programming and Scripting Linux 04-04-2013
Replies: 2
Views: 979
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)...
Forum: Shell Programming and Scripting Linux 04-04-2013
Replies: 4
Views: 1,629
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.
Forum: Shell Programming and Scripting Linux 04-03-2013
Replies: 5
Views: 12,543
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 08:05 PM.