LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 1329|回复: 7

一周一练

[复制链接]
发表于 2004-3-7 07:27:13 | 显示全部楼层 |阅读模式
1. Write a command that will give a quick indication of the total number of bash shells running on hills. Use the ps, grep, and wc utilities.

2. Write a command that removes all files that end in a “.log” extension, and do not contain your first name. Remove them from your home directory, and all subdirectories, recursively.

3. Write a command that produces ‘ls –f’ output for the current directory. But only lists files and directories for which the ‘other’ category (as opposed to ‘user’ and ‘group’ categories) has execution permission.

4. Write a command that invokes the who utility, and then filters the output so that only users who originally logged on before February 20th are listed.


Scripts:

For the script writing section, just write the lines of the script as they would appear in a text file.

1. Write a two line script that finds all of the files that end in a “.txt” in you home directory (and all subdirectories, recursively) and combines their contents into a single file named “combined.txt”, and then removes all of “.txt” files.

2. Rewrite the script so that is accepts one argument. The argument should represent a file extension. The new script should combine and delete all files that end in that file extension. If the script was named myCombineScript, for example, and if was invoked as follows:
bash> myScript ‘.temp’

Then the script should combine and delete all files that end in ‘.temp’. It should name the combined file “combined.temp”. You can accomplish this by carefully placing $1 into your script from question 1 above.


Extra

For this section, just write the lines of the sed script as they would appear in a text file.

Write a sed script that will modify any input stream in the following ways:

1. All digits from 0 to 4 should be replaced with lower case x’s.
2. All digits from 5 to 9 should be replaced with upper case X’s.
3. Any line that begins with a ‘#’ character, and otherwise only contains capital letters and spaces, should be deleted.
4. Any line that contains your last name, and ends with an exclamation point (!) should be written to a file named “mentioned”.
发表于 2004-3-8 02:11:21 | 显示全部楼层
我E文太差,能不能出点中/英文对照的,这样既做了练习又学了英文?...明天就买本<<计算机英汉辞典>> ;)
 楼主| 发表于 2004-3-8 10:27:58 | 显示全部楼层
最初由 javalee 发表
我E文太差,能不能出点中/英文对照的,这样既做了练习又学了英文?...明天就买本<<计算机英汉辞典>> ;)


加油啦!精神上支持你。  我在等你的好消息!
 楼主| 发表于 2004-3-8 10:49:10 | 显示全部楼层
我反译能力不行。 只能把大休的内容写出来,有错误的请指教。
我只能看明题目的意思,如果再用中文就有点难了... sorry.

1. 写一条命令,指出多少用户在hills (服务器名)running. 用ps, greep, wc 这一些命令


2. 写一命令除去全部文件的名是.log 扩展, 但我包含你的fist name 的.  除去他们在你的home
directory, 在全部的子目录.

3. 用ls -f 后,只是显示出other用名的属性,我要 user and group 的属性.


4. 用who 命令,显示出谁long on 在你的服务器,显示出来的是前于February 20th. 别的时间long on 的我要。


Scripts:

1.写二line scrip , 找全部是以".txt"结束的文件名在你的home directory (在所有的子目录),把所有的内客放入一个呼叫combined.txt 的文件。最后除去all of “.txt” files.

2.
发表于 2004-3-8 14:36:24 | 显示全部楼层
最初由 shaoping 发表
加油啦!精神上支持你。  我在等你的好消息!

谢谢,我会好自为之的!
 楼主| 发表于 2004-3-9 05:39:27 | 显示全部楼层
最初由 javalee 发表
谢谢,我会好自为之的!



那来帮我做几题啦!谢谢
发表于 2004-3-9 16:10:54 | 显示全部楼层
按我的理解:
1,
  1. who|awk '{print $1|"wc -l"}'
复制代码
2,
  1. for file in $(find -user "javalee" -prune -o -print -name "*.log");do
  2.         mv $file ${file%.*}
  3. done
复制代码
3,
  1. ls -F|grep *$
复制代码
4?
...
别的还没看明白的说!
 楼主| 发表于 2004-3-10 07:26:05 | 显示全部楼层
1.ps -ef|wc -l
2.find ~ -name \*.log|sed /li.log$/d |xargs rm

3.ls -f|ls -l|sed -e /^d/d|grep 'x$'
4.who |sed -e /Mar/d |sed -e /[Feb]\ \2[1-9]/d   


Scripts:
1.
find ~ -name \*.txt|tee combined.txt

find ~ -name \*.txt|xargs rm


2.要take a break
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表