Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

shell script for homework02 #3

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions homework/Key_01.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
根据如下表格,在可以操作的地方打上圈号,不可以操作的地方打上叉号。

目录权限 0 1 2 3 4 5 6 7
--- --x -w- -wx r-- r-x rw- rwx

ls X X X X OX O OX O
/bin/ls X X X X OX O OX O
cp file X O X O X O X O
rm file X X X O X X X O
nano file X O X O X O X O
cd X O X O X O X O

注:OX为如下的奇怪结果,只显示出文件名无其他信息。
captain@ubuntu:~$ ls -l linux*
ls: cannot access linux-homework/homework01: Permission denied
total 0
-????????? ? ? ? ? ? homework01



文件权限 0 1 2 3 4 5 6 7
--- --x -w- -wx r-- r-x rw- rwx

cp file X X X X O O O O
nano file X X X X O O O O
run X X X X X O X O
42 changes: 42 additions & 0 deletions homework/codes4homework02.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/bash
# Program:
# This program prints a 9*9 table on your screen.
# History:
# 2017/05/12 Captain First release

function mul
{
local x=$1
local y=$2
return $((x * y))
}

echo
echo "Let's rock!"
echo

for ((i = 1; i <= 9; i++))
do
if [ $i == 5 ]
then
echo "----------------:(----------------"
else
for ((j = 1; j <= 9; j++))
do
mul $i $j
result=$?
echo -n $result
if [ $result -gt 9 ]
then
echo -n " "
else
echo -n " "
fi
done
echo
fi
done

echo
echo "That's all."
echo
31 changes: 31 additions & 0 deletions homework/homework03.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash
# Author : Captain
# Date : May 22, 2017
# Purpose : Ouptput the top n words in a given English text file
#
if [ $# -ne 2 -a $# -ne 1 ]; then
echo "usage: `basename $0` [n] Input_File"
echo
exit
fi

if [ $# -eq 1 ]; then
I_TOP=10
I_FILE=$1
fi

if [ $# -eq 2 ]; then
I_TOP=$1
I_FILE=$2
fi

tr -sc 'A-Za-z' '[\012*]' < $I_FILE | \
tee debug.txt | \
tr 'A-Z' 'a-z' | \
sort | \
uniq -c | \
sort -k1 -n -r | \
head -$I_TOP | nl



53 changes: 53 additions & 0 deletions homework/homework04.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
//add.c

int add(int x, int y) {
return x+y;
}

//add.h
#ifndef _ADD_H_
#define _ADD_H_

int add(int x, int y);

#endif

//calc.c

#include <stdio.h>
#include "add.h"

int main() {
int x = 100;
int y = 100;
printf("%d + %d = %d\n", x, y, add(x, y));
return 0;
}

#Makefile
calc: calc.o libadd.a
gcc calc.o -o calc -I. -L. -ladd

calc.o: calc.c
gcc -c calc.c -o calc.o

libadd.a: add.o
ar -crv libadd.a add.o

add.o: add.c
gcc -c add.c -o add.o

clean:
rm -f calc calc.o libadd.a add.o adder.tar.gz

install: calc
sudo cp calc /usr/local/bin/calc

uninstall:
sudo rm -f hello /usr/local/bin/calc

dist: clean
mkdir adder
cp add.h add.c calc.c Makefile adder/
tar czvf adder.tar.gz adder
rm -fr adder
129 changes: 129 additions & 0 deletions homework/homework05.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
\documentclass[UTF8,12pt,a4paper]{ctexart}
\ctexset{
section/format += \raggedright
}
%\usepackage[UTF8, heading = true]{ctex}
\newcommand{\HRule}{\rule{\linewidth}{0.5mm}}
\usepackage{listings}
\usepackage{xcolor}
\usepackage{amsmath, amssymb}
\usepackage[hidelinks]{hyperref}


\usepackage{graphicx}
\usepackage{wrapfig}
\usepackage{subcaption}
\usepackage[font=small]{caption}

\usepackage{fancyhdr}
\pagestyle{fancy}
\lhead{
\includegraphics[width=0.05\textwidth]{./BUPT_LOGO.png}
}
\chead{北京邮电大学}
\rhead{[email protected]}
\lfoot{}
\cfoot{\thepage}
\rfoot{}
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\headwidth}{\textwidth}
\renewcommand{\footrulewidth}{0pt}

\usepackage[top=1in, bottom=1in, left=1.25in, right=1.25in]{geometry}
\setlength{\headheight}{26pt}
\usepackage{setspace}
\setstretch{1}%单倍行距

\usepackage{fontspec}
% 衬线字体:Linux Libertine
\setmainfont{Linux Libertine O}
% 无衬线字体:Linux Biolinum
\setsansfont{Linux Biolinum O}
% 等宽/打印机字体:Linux Libertine Mono
\setmonofont{Linux Libertine Mono O}

% 衬线字体:Noto Serif CJK SC
\setCJKmainfont{Noto Serif CJK SC}
% 无衬线字体:Noto Sans CJK SC
\setCJKsansfont{Noto Sans CJK SC}
% 等宽字体/打印机字体:Noto Sans Mono CJK SC
\setCJKmonofont{Noto Sans Mono CJK SC}

\usepackage{chemfig}
\usepackage{skak}

\begin{document}
\begin{center}
\large
\textbf{Linux操作系统第五次作业}

臧志强 2014210358

\today
\end{center}

\section{有趣的示例}
\begin{figure}[htbp]
\centering
\begin{subfigure}[b]{0.45\textwidth}
\centering
\newgame

\showboard
\caption{国际象棋}
\label{fig:chess}
\end{subfigure}
~
\begin{subfigure}[b]{0.45\textwidth}
\centering
\chemfig{
NO_2-[:90]*6(=-(-NO_2)=(-CH_3)-(-O_2N)=-)}
\caption{2,4,6 -- 三硝基甲苯(TNT)}
\label{fig:TNT}
\end{subfigure}
\caption{有趣的示例}
\label{fig:demoes}
\end{figure}

\section{Apocalypse Tank(天启坦克)}

\begin{quote}
The apocalypse has begun!
\end{quote}
The successor to the old Soviet Mammoth tank, the \textit{Apocalypse Assault Tank} (seen in figure \ref{fig:icon}) was a powerful heavy tank used by the USSR during the first and second iterations of the Third World War. It featured twin 120mm cannons, anti-air missiles, very heavy armour, and self-repair abilities, making it a force to be reckoned with on the battlefield.
\begin{figure}[h]
\centering
\begin{subfigure}[c]{0.1\textwidth}
\includegraphics[width=\textwidth]{RA2_Apocalypse_Tank_Icons.png}
\newline
\newline
\includegraphics[width=\textwidth]{RA2_Apocalypse_Tank_Veteran_Icons.png}
\end{subfigure}
~~
\begin{subfigure}[c]{0.5\textwidth}
\includegraphics[width=\textwidth]{RA2_Black_Guard_with_anti-aliasing.jpg}
\end{subfigure}
\caption{Apocalypse tank}
\label{fig:icon}
\end{figure}
% 作为老式苏维埃猛犸坦克的继承者,\textbf{天启突击坦克}是苏联在第三次世界大战的两次重演中使用的一种强大的重型坦克。 它装备有一对120mm火炮、对空导弹,同时拥有重装甲和自我修复能力,无疑是战场上的中坚力量。


% \begin{figure}
% \begin{center}
% \includegraphics[width=0.38\textwidth]{RA2_Apocalypse_Tank.png}\\
% \end{center}
% \label{fig:RA2_APOC}
% \end{figure}


% \chemfig{
% H_3C-[:72]{\color{blue}N}*5(-
% *6(-(={\color{red}O})-
% {\color{blue}N}(-CH_3)-
% (={\color{red}O})-
% {\color{blue}N}(-CH_3)-=)--
% {\color{blue}N}=-)}


\end{document}