本帖最后由 屋顶塔小猫 于 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大佬】 |