Last active
August 29, 2015 14:17
-
-
Save duyet/e0774adaec927ed8f6cd to your computer and use it in GitHub Desktop.
CE Lab UIT
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# viết chương trình cho phép nhập vào tên và mssv. Kiểm tra nếu | |
# mssv đó không trùng với mình thì bắt nhập lại. In ra màn hình kết quả. | |
# Van-Duyet Le <[email protected]> | |
# Homepage: http://lvduit.com | |
me=13520340 | |
mssv=0 | |
while [ $mssv -ne $me ]; do | |
read -p "MSSV: " mssv | |
done | |
echo 'MSSV: ' $mssv |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# viết chương trình cho phép nhập vào một số n. Kiểm tra nếu n < 10 | |
# thì bắt nhập lại. Tính tổng các số từ 1-> n. In kết quả ra màn hình | |
# Van-Duyet Le <[email protected]> | |
# Homepage: http://lvduit.com | |
n=0 | |
mssv=0 | |
while [ $n -lt 10 ]; do # n < 10 | |
read -p "n = " n | |
done | |
sum=0 | |
for i in $(seq 1 $n); do | |
sum=$((sum+i)); | |
done | |
echo 'SUM = ' $sum |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Find all string from input, and search all file (*.txt) contains this strings. | |
# viết trình cho phép nhập vào một chuỗi. Kiểm tra chuỗi đó có tồn tại | |
# trong một file text (ví dụ test.txt) cùng thư mục hay không | |
# Van-Duyet Le <[email protected]> | |
# Homepage: http://lvduit.com | |
ext="./*.txt" | |
read -p "Your input string: " input | |
echo 'List file containt "' $input '"' | |
# Option 1 ----------------------------- | |
for f in $ext | |
do | |
if grep -l $input $f; then | |
echo $f; | |
fi | |
done | |
# Option 2 ------------------------------ | |
# grep -r $input $ext | cut -d: -f1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment