Search Results

Search: Posts Made By: royalibrahim
1,692
Posted By Klashxx
In a oneliner: perl -ne 's/(\s*|\n)//g;print...
In a oneliner:
perl -ne 's/(\s*|\n)//g;print $_' inputfile
Inside a multiline script:
perl -e 's/(\s*|\n)//g && print $_ foreach (<>);' < inputfile
25,737
Posted By radoulov
The following statement is incomplete: backup...
The following statement is incomplete:
backup incremental level 1 tag Daily_Diff_Backup
format '/u01/app/oracle/backup/Daily_%T_L1_%db_df_%U_%t';Backup what :)? Database?
(in the example below...
11,803
Posted By balajesuri
Use raw string notation for regex: l =...
Use raw string notation for regex:
l = re.search(r"\b[A-Z]\S+", word)And just out of curiosity, any particular reason why you want to go for the regex method, as against continuing with python's...
1,744
Posted By MadeInGermany
The $1,$2 is a piece of awk code. You cannot...
The $1,$2 is a piece of awk code.
You cannot run a string (as assigned to an awk variable) as awk code.
(Unless there were an eval built into awk.)
This following awk code interprets a given...
1,744
Posted By Jotne
This works. ps | awk "{print $var}" Single...
This works.
ps | awk "{print $var}"

Single quote does not expand variable.
1,172
Posted By RudiC
A here document is something that is just read...
A here document is something that is just read (and expanded) and presented to stdin, and not executed per se. So the echo won't do anything. In the expansion phase, command substitution takes place,...
1,172
Posted By CarloM
If you want to disable substitution in a heredoc...
If you want to disable substitution in a heredoc then you need to quote the tag string:
<<'EOF'
echo "Sum is: `expr $1 + $2`"
EOF
26,117
Posted By MadeInGermany
.cshrc is automatically sourced csh -c 'exec...
.cshrc is automatically sourced
csh -c 'exec bash'
You need eval

eval $(
sed -rn 's/^\s*setenv\s+(\S+)\s+/export \1=/p' ~/.cshrc
)
Forum: Programming 09-26-2013
5,313
Posted By Corona688
Calling a member function "const" is to guarantee...
Calling a member function "const" is to guarantee to the compiler "this function modifies absolutely nothing in this class". You are calling a non-const member function(strlen) from a const member...
4,589
Posted By rajamadhavan
The best option for such requirement is Tie::File...
The best option for such requirement is Tie::File

In anyway, you need to seek to the beginning of the file before reading it again.


#! /usr/bin/perl -w

open FH, "+< testfile" or die "$@";...
Forum: Programming 06-12-2013
1,923
Posted By Corona688
I suspect you'll want to do both, actually, since...
I suspect you'll want to do both, actually, since there will be a \n on the end in both places.

This is a common enough need I usually make it a function:

void chomp(char *str)
{
int...
Forum: Programming 06-11-2013
1,923
Posted By Corona688
fgets(passwd, sizeof(passwd), stdin); ...
fgets(passwd, sizeof(passwd), stdin);
passwd[strlen(passwd) - 1] = '\0';

This looks to me like you're trying to add a null-terminator to the string.

strlen() only works when the string...
Forum: Programming 04-05-2013
4,964
Posted By JohnGraham
You're trying to make a template specialization,...
You're trying to make a template specialization, which means you need to use a concrete type instead of the generic T. So you could do e.g.:


template<> int* AddFun<int*>(int* i, int* j) {
...
8,398
Posted By vbe
compare : set prompt="[%/ $] " # and set...
compare :

set prompt="[%/ $] "
# and
set prompt = "-- %T %n %~ -- \n$ "

a Dollar sign followed by ANYTHING is unserstood by the shell as a variable...
Im sure you put:
set prompt="[%/ $ ] "...
1,415
Posted By durden_tyler
Here's the original one-liner: perl -lne...
Here's the original one-liner:


perl -lne 'print "$1\n$2" if /(HOST.*)\)\((.*?)\)/' input


and here's the only line in the input file on which matches the pattern:


Attempting to...
1,415
Posted By elixir_sinari
The options first: -n --> provides you a while...
The options first:
-n --> provides you a while loop by reading records (lines (terminated by new-lines) by default)
from the filename arguments without default printing (similar to sed -n)....
2,940
Posted By balajesuri
@royalibrahim: perl -n -e '#code' file is...
@royalibrahim: perl -n -e '#code' file is equivalent to
#! /usr/bin/perl
open F, "< file";
while (<F>) {
#code
}
close F;So, if you really want to do it by explicitly on command line by...
2,940
Posted By elixir_sinari
Of course, yes. You did it, right? Why would...
Of course, yes. You did it, right?

Why would perl complain when what you were doing was syntactically correct but logically wrong?

Never use a for (or foreach) loop to read a file. In this...
1,821
Posted By itkamaraj
$ perl -lane 'if($F[1]!~/test/){$F[1]="test" ....
$ perl -lane 'if($F[1]!~/test/){$F[1]="test" . "\u$F[1]";}print join " ",@F' input.txt
def testGroupGetVersion(self):
def testSetCurrentGroup(self, listID, listName, path, clientID):
2,885
Posted By guruprasadpr
Hi sed 'n;n;n;n;s/.*/QUERY\n&/;' file ...
Hi


sed 'n;n;n;n;s/.*/QUERY\n&/;' file

Guru.
2,885
Posted By Scrutinizer
Some sed do not know \n in the replacement part: ...
Some sed do not know \n in the replacement part:

sed 'n;n;n;n;s/^/QUERY\
/' infile

sed 'n;n;n;n;i\
query\
' infile



--
GNU sed:
sed '0~5s/^/QUERY\n/' infile
Forum: Programming 05-04-2012
2,225
Posted By Corona688
It doesn't. I think you didn't make your int...
It doesn't.

I think you didn't make your int static; static locals act like globals, they only get initialized once and keep their values between different function calls. Without static, the...
2,066
Posted By neutronscott
with this double quoting, look at PS1 after...
with this double quoting, look at PS1 after assignment:


$ PS1="[$PWD $(git branch | grep '*') $] "
[/home/mute $] declare -p PS1
declare -- PS1="[/home/mute \$] "


Your variables are...
5,850
Posted By vgersh99
echo '1|23||45|||6|' | sed 's/||*/|/g'
echo '1|23||45|||6|' | sed 's/||*/|/g'
Forum: Programming 03-16-2012
2,569
Posted By Corona688
When you assign one class to the other, all...
When you assign one class to the other, all you're copying is the pointer, not the memory itself. So they both end up holding pointers to the same memory.

When they go out of scope, they both try...
Showing results 1 to 25 of 55

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