Search Results

Search: Posts Made By: guruprasadpr
3,937
Posted By Don Cragun
When you have a pipeline, the standards allow...
When you have a pipeline, the standards allow (but do not require) the elements of the pipeline to be in different shell execution environments. If your system does put them in different shell...
1,595
Posted By elixir_sinari
.* will always be greedy and match as much as...
.* will always be greedy and match as much as possible (the whole line) but the parentheses and back-refs (in this case) force the regexp engine to back-track and give up one character of the matched...
1,595
Posted By Scrutinizer
TrY: grep -c '\(.*\).*(\1)' infile
TrY:
grep -c '\(.*\).*(\1)' infile
1,219
Posted By Scrutinizer
sed -e ':a' -e 's/\(([^)]*)\)\(.*\)\1/\1\2/;ta'...
sed -e ':a' -e 's/\(([^)]*)\)\(.*\)\1/\1\2/;ta' infile
45,086
Posted By alister
True. With regard to the original post, if...
True.

With regard to the original post, if the script is sourced, even if the shebang is present, it is never used.

Regards,
Alister

---------- Post updated at 10:02 AM ---------- Previous...
1,372
Posted By alister
A much less readable and maintainable version of...
A much less readable and maintainable version of agama's solution which is guaranteed to make whoever inherits the code mutter under their breath:

awk -F_ '!a[$1] && !a[$2] && ++a[$1] && ++a[$2]'...
2,554
Posted By cfajohnson
n=5 insertfile=/path/to/file { head -n...
n=5
insertfile=/path/to/file

{
head -n "$n"
cat "$insertfile" -
} < "$file"
2,394
Posted By Scrutinizer
That regular date with awk in post #1 will not...
That regular date with awk in post #1 will not work correctly on the first day of the month...

---
ksh93h+:
printf "%(%Y/%m/%d)T\n" yesterday
2,659
Posted By Scrutinizer
Note: That link contains some errors though,...
Note: That link contains some errors though, since EOF is not at the beginning of the line in the examples. And the double quotes are wrong and cannot be cut-and-pasted...
15,857
Posted By itkamaraj
$ cat one.pl #!/bin/perl use Time::Local; ...
$ cat one.pl
#!/bin/perl
use Time::Local;
my $date = $ARGV[0];
$date =~ s/\s+$//;
$date =~ s/^\s*//;
my ($year, $month, $day) = unpack "A4 A2 A2", $date;
eval{
timelocal(0,0,0,$day,...
1,797
Posted By Scrutinizer
Alternatively: awk 'getline p<f {print $1/p}'...
Alternatively:
awk 'getline p<f {print $1/p}' f=file1 file2
2,539
Posted By ygemici
#!/bin/ksh p="${0/.\//}" ps -ef|awk -vp="$p"...
#!/bin/ksh
p="${0/.\//}"
ps -ef|awk -vp="$p" '!/awk/&&/'$p'/{print "Script is in the -> " $(NF-1)}'
sleep 1


# ./check
Script is in the -> /bin/ksh
2,539
Posted By itkamaraj
i created a test.sh with the below contents and...
i created a test.sh with the below contents and just executed it.


$ cat test.sh
#!/bin/ksh
echo $SHELL
echo $0
while [ 1 ]
do
sleep 5;
done


after that, i tried one more...
Forum: Red Hat 01-25-2012
6,316
Posted By Corona688
simply put, root gets to break the rules.
simply put, root gets to break the rules.
35,941
Posted By jayan_jay
In this way we can sort $ cat...
In this way we can sort


$ cat hexanumbers.txt
3E80
3EF8
460
$ cat testfile.sh
#!/bin/ksh
for i in `cat hexanumbers.txt | awk '{ print "16#"$0}'`
do
typeset -i10 i
echo $i >>...
3,456
Posted By agama
This is a pure shell solution - should work in...
This is a pure shell solution - should work in bash as well.


#!/usr/bin/env ksh

while read first rest
do
printf "%04d %s %s\n" ${first/-/ } "$rest"
done <data-file
exit
1,787
Posted By Scrutinizer
GNU sed: sed 's/,,,*/\n&/2g' infile
GNU sed:
sed 's/,,,*/\n&/2g' infile
6,867
Posted By durden_tyler
Have you tested or benchmarked this claim? The...
Have you tested or benchmarked this claim?
The "grep" method essentially does a nested loop as well. It's just more concise and a more "Perlish" way of doing things.

With a setup consisting of...
2,074
Posted By Perderabo
# ls -li data 3180921 -rw-r--r-- 1 root root 42...
# ls -li data
3180921 -rw-r--r-- 1 root root 42 Feb 4 09:33 data
# sed -i 's/2/B/' data
# ls -li data
3180920 -rw-r--r-- 1 root root 42 Feb 4 13:24 data
#


The inode changed. It's a...
2,312
Posted By Scott
Hi. You have ^M characters in your input...
Hi.

You have ^M characters in your input file?

I get normal (expected) output, then added ^M characters and got:


awk '{print $3 ";" }' FS=, file1
;000
;000
;000
10,040
Posted By Scrutinizer
$ echo qwertmyuiop | sed ':a;s/.\(.*\)./\1/;ta' ...
$ echo qwertmyuiop | sed ':a;s/.\(.*\)./\1/;ta'
m

or
sed -e ':a' -e 's/.\(.*\)./\1/;ta'
8,033
Posted By Scott
Thanks for using indentation! The EOF mst be...
Thanks for using indentation!

The EOF mst be at the start of the line:


#!/bin/sh

echo "\nPress 1 for automated file dumping."
echo "Press 2 for manual file dumping."
echo "\nEnter your...
3,633
Posted By thegeek
instead of yy, copy the current line using y$ (...
instead of yy, copy the current line using y$ ( but you should be at the starting position to copy the line )..

go to the position where you want to paste, and press p to paste .. ( so it will not...
2,884
Posted By vgersh99
sed 's/\([^|][^|]*|\)\(.*\)/\2\1/' myFile
sed 's/\([^|][^|]*|\)\(.*\)/\2\1/' myFile
3,661
Posted By Scrutinizer
while read line do eval set -- "$line" ...
while read line
do
eval set -- "$line"
echo "$4"
done < infile
or:
print4()
{
echo "$4"
}

while read line
do
eval print4 "$line"
done < infile

or (ksh93/bash):
while read...
Showing results 1 to 25 of 28

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