bash_script
bash_script
mkdir mynewdir
cd mynewdir/
/mynewdir$ pwd
/mynewdir$ cp ../spider.txt .
/mynewdir$ touch myfile.txt
/mynewdir$ ls -l
#Output:
#-rw-rw-r-- 1 user user 0 Mai 22 14:22 myfile.txt
#-rw-rw-r-- 1 user user 192 Mai 22 14:18 spider.txt
/mynewdir$ ls -la
#Output:
#total 12
#drwxr-xr-x 2 user user 4096 Mai 22 14:17 .
#drwxr-xr-x 56 user user 12288 Mai 22 14:17 ..
#-rw-rw-r-- 1 user user 0 Mai 22 14:22 myfile.txt
#-rw-rw-r-- 1 user user 192 Mai 22 14:18 spider.txt
/mynewdir$ mv myfile.txt emptyfile.txt
/mynewdir$ cp spider.txt yetanotherfile.txt
/mynewdir$ ls -l
#Output:
#total 8
#-rw-rw-r-- 1 user user 0 Mai 22 14:22 emptyfile.txt
#-rw-rw-r-- 1 user user 192 Mai 22 14:18 spider.txt
#-rw-rw-r-- 1 user user 192 Mai 22 14:23 yetanotherfile.txt
/mynewdir$ rm *
/mynewdir$ ls -l
#total 0
/mynewdir$ cd ..
rmdir mynewdir/
ls mynewdir
#ls: cannot access 'mynewdir': No such file or directory
---------------------------------------------------------------
cat stdout_example.py
#!/usr/bin/env python3
print("Don't mind me, just a bit of text here...")
./stdout_example.py
#Output: Don't mind me, just a bit of text here...
./stdout_example.py > new_file.txt
cat new_file.txt
#Output: Don't mind me, just a bit of text here...
./stdout_example.py >> new_file.txt
cat new_file.txt
#Output: Don't mind me, just a bit of text here...
#Don't mind me, just a bit of text here...
cat streams_err.py
#!/usr/bin/env python3
----------------------------------------------------------------------------
ls -l | less
#(... A list of files appears...)
cat spider.txt | tr ' ' '\n' | sort | uniq -c | sort -nr | head
# 7 the
# 3 up
# 3 spider
# 3 and
# 2 rain
# 2 itsy
# 2 climbed
# 2 came
# 2 bitsy
# 1 waterspout.
cat capitalize.py
#!/usr/bin/env python3
import sys
cat haiku.txt
#advance your career,
#automating with Python,
#it's so fun to learn.
ping www.example.com
#PING www.example.com(2606:2800:220:1:248:1893:25c8:1946
(2606:2800:220:1:248:1893:25c8:1946)) 56 data bytes
Press Control C:
ping www.example.com
#PING www.example.com(2606:2800:220:1:248:1893:25c8:1946
(2606:2800:220:1:248:1893:25c8:1946)) 56 data bytes
fg
#ping www.example.com
#64 bytes from 2606:2800:220:1:248:1893:25c8:1946
(2606:2800:220:1:248:1893:25c8:1946): icmp_seq=5 ttl=51 time=93.6 ms
Press Control C:
Managing streams
These are the redirectors that we can use to take control of the streams of our
programs
These are some commands that are useful to know in Linux when interacting with
processes. Not all of them are explained in videos, so feel free to investigate
them on your own.
ps: lists the processes executing in the current terminal for the current user
kill PID: sends the SIGTERM signal to the process identified by PID
fg: causes a job that was stopped or in the background to return to the
foreground
top: shows the processes currently using the most CPU time (press "q" to quit)