valid phone numbers
Given a text file file.txt that contains list of phone numbers (one per line), write a one liner bash script to print all valid phone numbers.You may assume that a valid phone number must appear in one of the following two formats: (xxx) xxx-xxxx or xxx-xxx-xxxx. (x means a digit)
You may also assume each line in the text file must not contain leading or trailing white spaces.
Example:
Assume that file.txt has the following content:
987-123-4567
123 456 7890
(123) 456-7890
Your script should output the following valid phone numbers:
987-123-4567
(123) 456-7890
cat > file.txt <<EOF
987-123-4567
(123) 456-7890
0(001) 345-0000
(001) 123-345
linux awk 改变文件的内容的分隔符并添加行号
linux awk 改变文件的内容的分隔符并添加行号以下是范例内容,使用‘,’分隔符$ cat testfile.out
3232,32332,54545,34
3233,45645,23233,23
1211,1212,4343,434
3434,121121,121,33
替换文件内容中,为|并且为每行添加新的行号,输出结果为:
1|3232|32332|54545|34
2|3233|45645|23233|23
3|1211|1212|4343|434
4|3434|121121|121|33
linux 合并多个连续的行
linux 合并多个连续的行文件内容为:
$ cat infile.txt
aid=33
pw=3
nn=90
aid=32
pw=30
nn=70
aid=56
pw=3
nn=93
组合或合并上述文件的每三个连续行,使输出变为:
aid=33,pw=3,nn=90
aid=32,pw=30,nn=70
aid=56,pw=3,nn=93
linux 将0附加到单位数字日期
linux 将0附加到单位数字日期日期的文件格式为:month/day/year format.
$ cat date.txt
3/4/2013
3/10/2013
10/4/2013
12/10/2012
要求将0附加到单位数字日期,输入格式为
03/04/2013
03/10/2013
10/04/2013
12/10/2012
热门日志
分类
- Django(4)
- ssdb(1)
- Mac(7)
- C(1)
- memcache(1)
- Python(32)
- Vim(8)
- sed(2)
- ansible(3)
- awk(4)
- shell(3)
- about(1)
- git(9)
- bat(4)
- svn(0)
- docker(1)
- Tornado(1)
- go(2)
- 架构(18)
- Vue(1)
- game(2)
- Html(6)
- Java(8)
- Mysql(37)
- Ajax(2)
- Jsp(1)
- Struts(8)
- Linux(72)
- JavaScript(39)
- Staruml(0)
- Mouth(1)
- Php(102)
- Windows(8)
- Message(48)
- Lua(10)
- Compute(1)
- Redis(7)
- Nginx(12)
- Jquery(1)
- Apache(1)
- cocos2d-x(8)