/
View and Search Text and Directories
View and Search Text and Directories
Goal: Use various commands to view, inspect and search a text file.
Exercise: Setting Up
Question:
There is a folder called
intro_to_linux
within the/project/<project-name>/
folder.How would you copy this folder into your home folder?
Before moving on, please make sure you get this copied over correctly.
All further exercises assume you will be working within this folder, within the home folder
As you work through exercises take note of the
[]$ cd ~/intro_to_linux
- remember the tilda character~
is a shortcut for the home folder.
Setting Up: Answer(s)
Answer: There are a number of ways…
Method 01: Move into your home folder and copy into this location.
The .
marks the current working directory.
[]$ cd
[~]$ cp -r /project/<project-name>/intro_to_linux/ .
cp: cannot open 'intro_to_linux/workshop_me.txt' for reading: Permission denied
[~]$ ls
Desktop Documents Downloads intro_to_linux
[~]$ cd /project/<project-name>/
[<project-name>]$ cp -r intro_to_linux/ ~
cp: cannot open 'intro_to_linux/workshop_me.txt' for reading: Permission denied
[<project-name>]$ ls ~
Desktop Documents Downloads intro_to_linux
# -rw------- 1 <arcc-username> <project-name> 23 Oct 5 07:20 workshop_me.txt
View the content of files
Command | Description |
cat | |
more | |
head |
View the content of files
Command | Description |
tail |
Exercises: View Files: Give it a go.
Answers
Search for a string within a text file (grep)
Command | Description |
grep |
Examples: Search a file
Examples: Search folders and files
Exercises: Search Files
Answers
| Workshop Home | Next |
, multiple selections available,
Related content
Search for a File
Search for a File
More like this
Output Redirection and Pipes
Output Redirection and Pipes
More like this
Using the Terminal
Using the Terminal
Read with this
Intro to Linux Command-Line: View, Find, and Search
Intro to Linux Command-Line: View, Find, and Search
More like this
Vim and Vim Tutor
Vim and Vim Tutor
Read with this
The Linux File System
The Linux File System
More like this