全球主机交流论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

CeraNetworks网络延迟测速工具IP归属甄别会员请立即修改密码
查看: 1734|回复: 32

求助各位吊大的帮我写3个linux命令,红包60或者同济、sust

[复制链接]
发表于 2021-1-22 21:42:29 | 显示全部楼层 |阅读模式
本帖最后由 屋顶塔小猫 于 2021-1-22 22:56 编辑

Provide a Linux command line to accomplish each of the following tasks. Your answer in each subquestion
should consist of a single command or pipeline of commands, with no separating semicolons (;). (Please verify before
submitting that your solution consists of a single line. Use wc for this.) Before beginning this question, familiarize
yourself with the commands outlined on the Linux handout. Keep in mind that some commands have options not listed
on the sheet, so you may need to examine some man pages. Note that some tasks refer to a file myfile.txt. No
myfile.txt is given. You should create your own for testing.
1.
Print all (non-hidden) files/directories in any subdirectory of the current directory that end with lower-case .c
(immediate subdirectories only, not subdirectories of subdirectories). Do not use find. (Hint: there’s an easy
way to do this using only ls if you’re creative with globbing patterns.)
2.
Before attempting this subquestion, do some reading (either skim the man page or have a look on the Web) on the
awk utility. In particular, be sure you understand the effect of the command
awk ’{print $1}’ < myfile.txt
Give a Linux pipeline that gives a sorted, duplicate-free list of userids currently signed on to the (school) machine
the command is running on.


For each of the following text search criteria, provide a regular expression that matches the criterion, suitable
for use with egrep. Your answer in each case should be a text file that contains just the regular expression (i.e., you
don’t need to include the egrep command in your submitted solution), on a single line (again, use wc to verify this).
If your pattern contains special characters, enclose it in quotes
3.
Lines consisting of a definition of a single C variable of type int, without initialization, optionally preceded by
unsigned, and optionally followed by any single line // comment. Example:
int varname; // optional comment
You may assume that all of the whitespace in the line consists of space characters (no tabs). You may also assume
that varname will not be a C keyword (i.e., you do not have to try to check for this with your regular expression).

求助各位吊大的,写完60红包奉上或者可以选一个同济或者一个sust,QQ联系我,或者私信我带上支付宝账号
【感谢h2o大佬】
 楼主| 发表于 2021-1-23 01:21:47 | 显示全部楼层
testsun 发表于 2021-1-23 01:16
大佬贴下h20大佬的答案呗,参考比较一下


1. ls -R */*[a-z].c
2. who | awk '{print $1}' | xargs -i id -u {} | sort -n | uniq
3. ' *(unsigned)? *int .*?;'

by h20
imes 该用户已被删除
发表于 2021-1-22 23:48:42 来自手机 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
发表于 2021-1-22 21:45:30 | 显示全部楼层
先机翻一下

1。打印当前目录中任何以小写.c结尾的子目录中的所有(非隐藏)文件/目录(仅直接子目录,而不是子目录的子目录)。
不要使用查找。 (提示:有一个简单的方法如果您对浮动模式很有创意,可以只使用ls来完成此操作。)

2。在尝试此子问题之前,请先阅读以下内容(浏览手册页或在Web上浏览)。awk实用程序。
特别是,请确保您了解该命令的效果
awk‘{print $ 1}’<myfile.txt
提供一个Linux管道,该管道提供当前已登录(学校)计算机的用户ID的排序,无重复列表该命令正在运行。

3。由一个类型为int的C变量的定义组成的行,无需初始化,可以选择后面加上无符号的,并且可以选择在其后加上任何单行//。 例:
int varname; //可选注释
您可以假定该行中的所有空格都由空格字符(无制表符)组成。 您也可以假设该varname不会是C关键字(即,您不必尝试使用正则表达式对此进行检查)。
发表于 2021-1-22 21:42:56 | 显示全部楼层
本帖最后由 dforel 于 2021-1-22 22:02 编辑

好多英文。看不懂怎么办

第一题不能用find,能不能用grep呢?

比如
ls . |grep ".c$"

第二题

cat myfile.txt | awk '{print $1}' |  sort | uniq

瞎写 的,没试过。。
发表于 2021-1-22 21:45:53 来自手机 | 显示全部楼层
rm-f 简单快捷
 楼主| 发表于 2021-1-22 21:46:40 | 显示全部楼层

不是应该rm -rf /*吗,哈哈
发表于 2021-1-22 21:48:04 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
发表于 2021-1-22 21:48:19 | 显示全部楼层
这是 CS 专业作业吧?
 楼主| 发表于 2021-1-22 21:49:02 | 显示全部楼层
h20 发表于 2021-1-22 21:48
多少红包,我再看看接不接

60
发表于 2021-1-22 21:53:41 来自手机 | 显示全部楼层
本帖最后由 jsenet 于 2021-1-22 22:07 编辑

我好像想多了
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|全球主机交流论坛

GMT+8, 2024-4-26 09:16 , Processed in 0.067498 second(s), 13 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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