Search Results

Search: Posts Made By: ahmad.diab
1,871
Posted By ahmad.diab
you can use awk,nawk or gawk:- gawk...
you can use awk,nawk or gawk:-




gawk '{for(i=2;i<=NF;i++){print $1,$i}}' FS="," OFS="," infile.txt > outfile.txt



BR
:D:D:D
3,663
Posted By ahmad.diab
another way:- gawk '/^R/&&s{print s ;...
another way:-

gawk '/^R/&&s{print s ; s=""}{s=s$0}END{printf s}' file.txt


o/p
R|This is line 1
R|This is line 2
R|This is line 3
R|This is line 4
R|This is line 5


BR
;););)
3,663
Posted By ahmad.diab
and to eliminate the space from beginning do the...
and to eliminate the space from beginning do the code:-

gawk '/^R/&&s{sub(/^[ ]/,"",s) ; print s ; s=""}{s=s" "$0}END{sub(/^[ ]/,"",s);printf s}' file.txt
3,663
Posted By ahmad.diab
huaihaizi3:- what if "This is Line 1" is...
huaihaizi3:-

what if "This is Line 1" is containing more than 4 args?

---------- Post updated at 18:01 ---------- Previous update was at 17:49 ----------

or even you can do below:-

gawk...
13,370
Posted By ahmad.diab
you can use nawk , awk , gawk: nawk -F":"...
you can use nawk , awk , gawk:


nawk -F":" '{print $NF}' infile > outfile
2,253
Posted By ahmad.diab
you can do below if interested with one liner:- ...
you can do below if interested with one liner:-

perl -07 -wlpe 's/(.*)\s+~+/## $1/s ;' infile.txt

:D:D:D
81,982
Posted By ahmad.diab
you forget to escape \ with \. sed...
you forget to escape \ with \.


sed 's/\\x0D/\\x0D \\x0A/g'

:D:D:D:D
3,245
Posted By ahmad.diab
FYI:- A hard link can point only to a file...
FYI:-

A hard link can point only to a file and not to a directory, and only to a file existing on the same file system where the link itself is.
A symbolic link, in contrast, can point to a file...
3,477
Posted By ahmad.diab
kindly give the input and the desired output ...
kindly give the input and the desired output

---------- Post updated at 06:11 AM ---------- Previous update was at 05:27 AM ----------

use below , and write the code as you can see it in below...
6,331
Posted By ahmad.diab
if you want to use Perl for predefined date you...
if you want to use Perl for predefined date you can use below code:-


#!/usr/bin/perl -l

use Date::Parse;
print str2time("Mon Apr 18 16:45:00 UTC 2011"); #1303145100
print...
15,500
Posted By ahmad.diab
awk -F, 'FNR==NR{f1[$1]=$0;next}$2 in f1{print...
awk -F, 'FNR==NR{f1[$1]=$0;next}$2 in f1{print f1[$2],$0}' OFS="," file1 file2
3,757
Posted By ahmad.diab
use below:- gawk -F"," '{...
use below:-



gawk -F"," '{ split($3,a,"\/") ; if ( a[2] < 10) {$3=a[3]a[1]"0"a[2]}
else {$3=a[3]a[1]a[2] }}1' OFS="," file.txt


:D:D:D:D
4,558
Posted By ahmad.diab
another try:- perl -F"," -wlane ' (@a =...
another try:-


perl -F"," -wlane '
(@a = @F) and next if $.==1 ;
$i = 0 ;
map { s/^\s+// ; push @{$_},$F[$i++] } @a ;
END {
map { $j=$_ ; map { print $_,"[$j]"," = ",${$_}[$j] } @a ;print...
9,789
Posted By ahmad.diab
use below: form line to paragraphs: ...
use below:

form line to paragraphs:

perl -wlne '$_ =~ s/\s+/\n/g;print $_,"\n";' infile.txt > outfile.txt


for reverse:
from paragraphs to lines:

perl -00 -wne 's/\n/\t/g;print $_,"\n"'...
4,311
Posted By ahmad.diab
using Perl:- perl -wlne 'printf "$1 " while...
using Perl:-

perl -wlne 'printf "$1 " while (s/\"(.*?)\"//);' infile.txt

;););)
5,857
Posted By ahmad.diab
Really nice post , but I would like to suggest...
Really nice post , but I would like to suggest another technique using Perl:-


perl -wle '
open(IN , "<in.txt") or die "can not open$!\n" ;
open(OUT , "<out.txt") or die "can not open$!\n" ;...
1,954
Posted By ahmad.diab
if you don't have the -i option on sed use PERL...
if you don't have the -i option on sed use PERL code below:

perl -i -wlpe 's/TRASH_MAX_SIZE:1024/TRASH_MAX_SIZE:2040/;' config.ini

:b::b:
10,548
Posted By ahmad.diab
it is more simpler if you use associative array...
it is more simpler if you use associative array below:-

Note:- in solaris use nawk instead of awk.


awk 'NR==FNR{a[ int( substr($0,1,9) )] ; next}(FNR in a)' fileA fileB


BR
...
Showing results 1 to 18 of 18

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