19.- grep
The grep is a filter that is used to search for lines matching a specified pattern and print the matching lines.
https://www.thegeekstuff.com/2009/03/15-practical-unix-grep-command-examples/
grep “seis” /mnt/sdcard/AppInventor/assets/numeros.txt
grep -r “seis” /mnt/sdcard/AppInventor/assets/numeros.txt
grep -v -e “six” /mnt/sdcard/AppInventor/assets/numeros.txt
grep -o -b “seven” /mnt/sdcard/AppInventor/assets/numeros.txt
grep -n “six” /mnt/sdcard/AppInventor/assets/numeros.txt
shell_grep.aia (11.5 KB)
2 Likes
20.- gunzip ::: gzip
gzip: zip and unzip
gunzip: unzip
gzip --help
gzip -k -c /mnt/sdcard/AppInventor/assets/numeros.txt > /mnt/sdcard/the_numeros.txt.gz
gzip -d -c /mnt/sdcard/the_numeros.txt.gz > /mnt/sdcard/los_numeros.txt
shell_gzip.aia (11.0 KB)
3 Likes
21.- head ::: tail
head -n 3 /mnt/sdcard/numeros.txt (shows the first three lines of the file)
tail -n 2 /mnt/sdcard/numeros.txt (shows the last two lines of the file)
1 Like
22.- ifconfig ::: ip ::: iw
ifconfig is used in LINUX to show/change network configuration,
but to modify the configuration you need to be root.
ifconfig wlan0 (shows IP)
ip net-tools which is used for performing several network administration tasks.
ip
ip address show wlan0
ip n show
ip neigh show
ip -s neigh
ip -neighbour (to view MAC address of the devices connected to your system.)
iw (similar to ip)
1 Like
23.- kill ::: killall
kill command sends a signal to a process, if signal is 9 (default) kill a procces.
Linux kill command help and information with kill examples, syntax, related commands, and how to use the kill command from the command line.
ps (get PID of process)
kill 19260 (kill MIT Companion)
killall edu.mit.appinventor.aicompanion3 (kill process by name )
3 Likes
24.- ln ::: logcat ::: logname
ln creates hard links by default, or symbolic links with -s ( –symbolic ), it is a very important command in LINUX, but I cannot use it with AI2.
Linux ln command help and information with ln examples, syntax, related commands, and how to use the ln command from the command line.
logcat -t 300 ( is a command -line tool that dumps a log of system messages)
logname (“name” user, example: u0_a173)
1 Like
25.- ls
list of files and directories.
https://www.thegeekdiary.com/basic-ls-command-examples-in-linux/
ls -ali /mnt/sdcard/
-a (all, hidden .files)
-l (long format)
-i (show i-node number)
ls -ali /mnt/sdcard/ | grep 4096 (filter with grep lines with number 4096 (size))
ls -ali /mnt/sdcard/DCIM/
ls -ali /mnt/sdcard/DCIM/Camera > /mnt/sdcard/list_my_photos.txt
1 Like
26.- md5sum
Similar to cksum
md5sum --help
md5sum /mnt/sdcard/numeros.txt
return
74c22f5af060ac90932f7354261d887b numeros.txt
27.- mkdir
Create directory.
mkdir /mnt/sdcard/my_new_directory
mkdir -p /mnt/sdcard/directory/subdirectory/subsubdirectory
1 Like
28.- mount
mount , shows where the devices are mounted.
To mount devices you need to be root #
29.- mv
mv, move a file or directory, also used to rename a file or directory.
mv /mnt/sdcard/numeros.txt /mnt/sdcard/new_numeros.txt
1 Like
30.- netstat
netstat, list out all the network (socket) connections.
netstat.
ABG
April 7, 2020, 4:08pm
42
curl opens up possibilities in REST API calls.
2 Likes
31.- ping
ping, to check the network connectivity between host and server/host.
ping -c 3 google.com (sends 3 packets)
ping -c 3 192.168.1.1
32.- printf
printf prints a formatted string to the standard output.
printf “My name is “%s”.\nIt’s a pleasure to meet you.” “John”
printf “%d plus %5f %s %.*f.” 5 5.05 “equals” 3 10.05
printf ‘hello\nworld\n!’
Examples from:
33.- ps ::: pm
ps , list process.
ps --help
ps -A
oooooooooOOOooooooooo
pm , package manager
pm list packages
pm list packages -f
pm list packages -s
pm list features
pm list packages --show-versioncode
https://adbshell.com/commands/adb-shell-pm-list-packages
34.- rm ::: rmdir
rm, remove file.
rm -r, recursive, remove directory contents.
rmdir, remove directory.
35.- sed
sed, stream editor.
This is a very simple example, change the word five to FEVER in the file /mnt/sdcard/numeros.txt
uno,one,un
dos,two,deux
tres,three,trois
cuatro,four,quatre
cinco,five ,cinq
sed ‘s/five/FEVER/’ /mnt/sdcard/los_numeros.txt
uno,one,un
dos,two,deux
tres,three,trois
cuatro,four,quatre
cinco,FEVER ,cinq
sed --help
1 Like
36.- service
service command starts, stops, list services.
service list
service --help
37.- sleep ::: sort
sleep 4
sort , sorts lines of text files. It supports sorting alphabetically, in reverse order, by number, by month and can also remove duplicates.
sort /mnt/sdcard/numeros.txt
sort /mnt/sdcard/numeros.txt > /mnt/scdard/sort_numeros.txt
sort -r /mnt/sdcard/numeros.txt (reverse)
sort -u /mnt/sdcard/numeros.txt (no duplicates)
sort -k 2 -t , /mnt/sdcard/numeros.txt
Tutorial on using sort, a UNIX and Linux command for sorting lines of text files. Examples of alphabetical sorting, reverse order sorting, sorting by number and mixed case sorting.