Search Results

Search: Posts Made By: LessNux
6,833
Posted By drl
Hi. Similarly, given file data1: abc def...
Hi.

Similarly, given file data1:
abc
def
ghi
jkl
and perl code p1:
#!/usr/bin/env perl

# @(#) p1 Demonstrate slurp and single-string match.

use strict;
use warnings;

my $a =...
6,833
Posted By Scrutinizer
perl -pe operates on a line-by-line basis, so it...
perl -pe operates on a line-by-line basis, so it will not match a multiline pattern
You could try something like (within a paragraph):
perl -00 -pe 's/a.*f/z/s' file
or (within a file)
perl -0777...
13,697
Posted By Scrutinizer
Hi, try: sort -bt. -k1,1 -k2,2n -k3,3n -k4,4n...
Hi, try:
sort -bt. -k1,1 -k2,2n -k3,3n -k4,4n -k5,5n
6,082
Posted By Chubler_XL
I think it's at assignment: $ T=$(printf...
I think it's at assignment:

$ T=$(printf "A\x0B")
$ echo ${#T}
2

$ T=$(echo "AAA" | sed "s:A:\x0:"g)
$ echo ${#T}
0

I suspect bash uses the standard C string functions to deal with...
10,563
Posted By methyl
Check the << bit of your bash man pages. If you...
Check the << bit of your bash man pages.
If you quote any part of the here document terminator it disables parameter substitution within the here document:
cat > child.sh << \EOF



The other...
10,563
Posted By pludi
There's a neat little trick the shell allows you...
There's a neat little trick the shell allows you to use. Compare these 2 runs:
$ var=foo
$ cat << EOF
> echo $var
> EOF
echo foo
$ cat << 'EOF'
> echo $var
> EOF
echo $var
50,649
Posted By agama
No math needed: foo="hello world" echo...
No math needed:


foo="hello world"
echo ${foo%?}
hello worl
4,717
Posted By Chubler_XL
As you can tell LessNux we are very concerned...
As you can tell LessNux we are very concerned with the security implications of using eval against user entered data. There are a few limited situations where using eval could be OK but in general...
2,784
Posted By Corona688
You read input from stdin by using the special...
You read input from stdin by using the special STDIN file descriptor.

print "Type something and hit enter: ";
$LINE=<STDIN>;
2,784
Posted By pseudocoder
Corona688's answer is pretty right, but don't...
Corona688's answer is pretty right, but don't forget to chomp!
chomp removes the newline character from the end of line.
chomp($LINE);
the line input operator includes the newline at the
end of...
3,585
Posted By durden_tyler
$ $ # display the data file $ cat -n...
$
$ # display the data file
$ cat -n data_file
1 this is line 1
2 this is line 2
3 i want to substitute this => ~ <= by that => # <=
4 at multiple places => abc~ def~ghi...
3,662
Posted By durden_tyler
Are you okay with removing the "p" switch? It's...
Are you okay with removing the "p" switch?
It's similar to the "n" switch, but it prints the input line by default (similar in function to the "p" switch of sed).

For example, if your shell...
7,084
Posted By durden_tyler
$ $ # Bash command $ cat testfile this is a...
$
$ # Bash command
$ cat testfile
this is a test file
$
$
$ # Perl program
$ cat -n call_bash.pl
1 #!/usr/bin/perl -w
2 # Call Bash command
3 system ("cat testfile");
$...
44,388
Posted By Scrutinizer
-a and -o are deprecated... For POSIX compliancy...
-a and -o are deprecated... For POSIX compliancy use:

if test 1 -eq 1 && ( test 2 -eq 2 || test 3 -eq 3 )
then
echo "true"
else
echo "false"
fi

or the synonym:
if [ 1 -eq 1 ] && ( [ 2...
Showing results 1 to 14 of 14

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