adjust directory 2

This commit is contained in:
JamesonHuang
2015-06-28 14:39:56 +08:00
parent b09950bf62
commit 4039994946
1767 changed files with 503365 additions and 0 deletions

View File

@ -0,0 +1,14 @@
local val = "1,2,3,4,5,6,0"
--local val = "1,2,3,4,5,6,0"
--local val = "1,2,3,4,5,6,0"
--local val = "1,3,5"
local repeat_var = "0000000"
for i = 1, #val, 2 do
idx = string.sub(val, i, i)
if idx ~= tostring(0) then
repeat_var = string.sub(repeat_var, 0, idx - 1) .. tostring(1) .. string.sub(repeat_var, idx + 1, #repeat_var)
else
repeat_var = string.sub(repeat_var, 1, #repeat_var - 1) .. tostring(1)
end
print(repeat_var)
end

View File

@ -0,0 +1,2 @@
local str = "hello world!"
print(string.sub(str, -3, -1))

View File

@ -0,0 +1,22 @@
--[[print("lua")
tmp2 = os.date("!*t")
print(tmp2)
tmp = os.date("*t")
print(os.date())
print(tmp)
local x = os.time()
print(x)
]]--
print(os.date(now))
print(os.date("%x"))
print(os.date("%M"))
print(os.date("*t", now)) --table
print(os.date("!*t", now)) --UTC
--字符串形式
local tmp = os.date(now)
print(tmp)
--转table
local tmp2 = os.date("!*t", tmp)
print( os.time(tmp2))

View File

@ -0,0 +1,38 @@
---------------------Lua遍历字符串的每个字符-----------------------
local s = "hello hi, again"
print(string.len(s))
--[[----failed,expected table, not a string
for i, v in ipairs(s) do
print(v)
end
]]--
--[[success
for i = 0, #s do
print(string.sub(s, i, i))
end
]]--
--------------------------wifi repeat代码--------------------------
local repeat_var_from_http = "1111111"
if string.len(repeat_var_from_http) ~= 7 then
print("len error")
return
end
local week_repeat = ""
for i = 1, #repeat_var_from_http do
tmp = string.sub(repeat_var_from_http, i, i)
if tmp == "1" then
if(i == #repeat_var_from_http) then
week_repeat = week_repeat..0
break
end
week_repeat = week_repeat..tostring(i)..","
end
end
print(week_repeat)

View File

@ -0,0 +1,2 @@
local var = 10 > 9 and 10 or 9
print(var)

View File

@ -0,0 +1,25 @@
#!/usr/bin/env python
# coding=utf-8
#遍历字符串每个字符
word = 'helloworld!'
str = "strcat method4: "
for letter in word:
print "strcat method1: " + letter
print "strcat method2: ", letter
print "strcat method3: %s" %(letter)
#print str.join(letter) #fail
#遍历数组元素
words = ['hello', 'world']
for word in words:
print "word:",word
#forint i = 0 i < 10; i += 2
for num in range(0, 10, 2):
print num
#index
for index in range(len(words)):
print words[index]

View File

@ -0,0 +1,15 @@
#* * * * * echo "hello" >> /cron.txt
#* * * * * echo "face" >> /cron.txt
#* * * * * echo "null" >> /cron.txt
#* * * * * echo "teee" >> /cron.txt
#* * * * * echo "test" >> /cron.txt

View File

@ -0,0 +1,10 @@
移除空白行:
sed -i '/^$/d' file
在指定行前加#号,注释该行:
sed -i '/tacb/s/^/#/g' /etc/crontabs/root
取消#号,取消注释:
sed -i '/hello/s/^#//' /etc/crontabs/root
cat t.txt|sed -n -e 's/^#\(.*\)/\1/p'