Code:
import fileinput
for line in fileinput.FileInput("file", inplace=1):
line=line.replace("old","new")
print line
import fileinput
for line in fileinput.FileInput("file", inplace=1):
line=line.replace("old","new")
print line
$array1=array(3,7,12,56,89); print_r($array1); $array2=array(12,89,3,7,56); print_r($array2); $array1=$array2; print_r($array1);
>>> import string >>> x="abc123" >>> x.strip(string.letters) '123' >>> x="123abc" >>> x.strip(string.letters) '123' >>>
echo "/home1/pandadk/sandbox/odm/odm_daa/pub_odm_daa_test1/run" | tr "/" "\n"
echo "/home1/pandadk/sandbox/odm/odm_daa/pub_odm_daa_test1/run" | awk '1' RS="/"
>>> a=1234 >>> list(str(a)) ['1', '2', '3', '4']
if not [i for i in a if not i.isdigit()]: print "True"
while read line do # echo $line done < file
rm -rf /usr/[0-1][0-9][0-9] rm -rf /usr/200
myfile="/home/myfile"
for lines in open(myfile): # equivalent of unix cat (or other tools for file reading)
print lines
# more file
123232 3232 2323 2323123123213 trterert
# more file1
123232 3232 2323 2323123123213 XXXXXXXX
123232 3232 2323 2323123123213 trterert
# ./test.sh
123232 or trterert not in line 1
123232 3232 2323 2323123123213 trterert
# cat test.sh
#!/bin/sh
awk 'FNR==NR{ a[FNR]=$0;next }
{
for( i in a ){
if ( ( a[i] ~ $1) && ( a[i
>>> import textwrap >>> s="123456" >>> textwrap.wrap(s,3) ['123', '456']
Leave a comment: