CLOs - Working With Files Flashcards
What are basic commands for viewing files and what do they do?
cat - viewing files that are not very long, no scroll-back provided
tac - viewing a file backwards, starting with last line
less - viewing larger files, paging program, lets search and navigate within file, scroll-back, space for next page, -N for line numbers
tail - print last 10 lines of file by default, with -n 15 or just -15 changes it to the 15 last lines
head - opposite of tail
what does command do?
wc
Word count gives information about word count, line count etc of file
What does this command do?
cat -n
Shows file with line numbers
What does this command do?
touch file
- update the access, change and modify times of files
- by default resets files timestampt to match current time
- can also be used to create empty files
How can you create new directories?
mkdir sampdir -> creates sample directory named sampdir under current directory
mkdir /usr/sampdir -> creates sample directory under /usr
How do you remove an empty directory? Or a directory and all of its contents? How can you do it interactively?
rmdir -> empty directory
rm -rf -> recursive
rm -i -> interactively before every removal
What does this command do?
mv
- simply rename a file
- move a file to another location, while possibly changing its name at the same time