Tag Info

New answers tagged

1

You can do something like: #! /usr/bin/env python device = '/dev/sdi' old_pattern = "MyPassWord" new_pattern = "XXXXXXXXXX" assert len (old_pattern) == len(new_pattern) BS = 1024 ** 2 # 1 Mb buffer # read a few bytes more to account for occurences of the pattern on the edge READSIZE = BS + len(old_pattern) offset = 0 with open(device, 'r+b') as fp: ...


1

sed "s/\([AB]\)\1\1*/\n&\n/g s/AA\n\([[:alnum:]]\{1,\}\)\nBB/CC\1DD/g s/\n//g " <<\INPUT AAHelloBB Text AAByeByeBB INPUT I think that should only do the AA>>CC&&BB>>DD replacement if there is 1 or more alphanumeric character[s] between the two groups and should always squeeze the possible occurrences as near to each ...


2

This is basic task for sed command: sed 's/AA\(someArbitraryString\)BB/CC\1DD/g' Eventually if you want to do this for all "arbitrary strings": sed 's/AA\(.*\)BB/CC\1DD/g'


6

awk -F":" '{OFS=":"; print $1,$2,$3,$4-5,$5+5}' filename Output: 1314:Battery:1.90:45:35


3

With perl: perl -i -F: -lape '$F[3]-=5;$F[4]+=5;$_=join ":",@F' the-file With sh (assuming those numbers are always decimal integers without leading zeros): IFS=: read -r a b c d e < the-file && printf '%s\n' "$a:$b:$c:$((d-5)):$((e+5))" > the-file With recent versions of GNU awk: gawk -i inplace -F: -vOFS=: '{$4-=5;$5+=5}1' the-file


1

Through Ctrl+R you switch into the search & replace mode. In the bar on the bottom, you first have to select as Mode either Escape sequences or Regular expressions. For instance, if you choose Escape sequences, click the right mouse button on the search field. A context menu appears with an item called Add, listing some valid escape sequences, among ...


0

Using \n to represent a newline works in gedit and most other editors I've tried, it should work in Kate too, does it? Even selecting 2 lines and "dragging" them, or copy the 2 lines together and paste into gedit's search box copied the text with the \n in the correct spot. Kate's webpage advertises "support for multiline search & replace"



Top 50 recent answers are included