Tag Info

New answers tagged

1

If your file filename has something like below abcd 1234 djhd 6534 fytf 4544 You could execute a AWK one liner like this index=2;for i in cat filename; do echo $i; done|awk -v OFS=" " -v INDEX=$index '$1 ~ /^abcd$/ {$2="1233"; print }' >> NewFile.txt This will match the name dddd & replace the number 1234 with 1233. This will redirect the ...


1

OMG! Im so stupid. I finally found the error here. The regEx is just fine and working properly. Its the grep option '-L' that is totally crap. Its supposed to be '-l' to just return the path and filenames that matches. grep -l -R -e 'https://hostname/' /srv/www/htdocs/intranet/data/pages/*.txt | xargs -n1 sed -i.bak ...


0

I recommend to debug on one selected file: sed 's|something|replacement|g' a_file.txt to see what happens. When your regular expression is debugged, you can simplify your command like this: shopt -s globstar sed -i.bak 's|https://hostname/|https://hostname.fq.dn|g' /srv/www/htdocs/intranet/data/pages/{,**/}*.txt There's no need for the grep and xargs. ...


4

As your log files have the good taste of having timestamps that are lexicographically sorted, you can simple compare strings using awk, eg: awk 'substr($0,1,17)>="20150720 15:06:00" && substr($0,1,17)<="20150720 16:25:00"' <logfile.log I've assumed here that your timestamp starts at column 1 (numbering from 1). If not, change the ,1, ...



Top 50 recent answers are included