zeus
4 years ago
14 changed files with 49607 additions and 0 deletions
@ -0,0 +1,11 @@ |
|||||
|
|
||||
|
echo "Cutting Contents of a file on the standard output (stdout)." |
||||
|
echo "----------------------------------------------------------" |
||||
|
|
||||
|
cut -b1,3 $LLO_DATAFILE | head -5 |
||||
|
echo "" |
||||
|
|
||||
|
echo "Cutting Contents of a file on the standard output (stdout)." |
||||
|
echo "-------------------with ranges---------------------------------------" |
||||
|
|
||||
|
cut -b1-5,10-15 $LLO_DATAFILE | head -5 |
@ -0,0 +1 @@ |
|||||
|
grep "Jordan" | cut -b 8- $LLO_DATAFILE | head -5 |
@ -0,0 +1,2 @@ |
|||||
|
|
||||
|
-b It uses a special form: selecting bytes upto the end of the line |
File diff suppressed because it is too large
@ -0,0 +1,36 @@ |
|||||
|
|
||||
|
Cut parts of a line by *byte position*, *character* and *field*. |
||||
|
|
||||
|
Cut command slices a line and extracts the text. It is necessary to specify option with command otherwise it gives error. |
||||
|
|
||||
|
|
||||
|
[source,bash] |
||||
|
---- |
||||
|
cut OPTION [FILE] |
||||
|
e.g. |
||||
|
cut $LLO_DATAFILE | head -5 |
||||
|
---- |
||||
|
|
||||
|
*-b(byte):* To extract the specific bytes, you need to follow -b option with the list of byte numbers separated by comma. |
||||
|
|
||||
|
[source,bash] |
||||
|
---- |
||||
|
cut -b 1,2,3 $LLO_DATAFILE | head -5 |
||||
|
---- |
||||
|
|
||||
|
|
||||
|
[INFO] |
||||
|
==== |
||||
|
|
||||
|
DATAFILE |
||||
|
|
||||
|
The datafile contains aggregate individual statistics for 67 NBA seasons. from basic box-score attributes such as points, assists, rebounds etc., to more advanced money-ball like features such as Value Over Replacement. |
||||
|
|
||||
|
Take a look in |
||||
|
link:https://git.swarmlab.io:3000/llo/LabLearningObject/src/branch/master/data/nba_statistics_glossary[Glossary^] |
||||
|
for a detailed column description |
||||
|
|
||||
|
ENVIRONMENT VARIABLE: LLO_DATAFILE |
||||
|
|
||||
|
==== |
||||
|
|
@ -0,0 +1,9 @@ |
|||||
|
|
||||
|
Try to run |
||||
|
|
||||
|
[source,sh] |
||||
|
---- |
||||
|
cut -b 3- $LLO_DATAFILE | head -5 |
||||
|
---- |
||||
|
|
||||
|
and see the Results! |
@ -0,0 +1,25 @@ |
|||||
|
|
||||
|
echo 'Display tab characters as ^I' |
||||
|
echo "-------------------------------" |
||||
|
|
||||
|
cat -T $LLO_DATAFILE | head -9 |
||||
|
echo "" |
||||
|
|
||||
|
echo "Display non printing characters" |
||||
|
echo "-------------------------------" |
||||
|
|
||||
|
cat -v $LLO_DATAFILE | head -9 |
||||
|
echo "" |
||||
|
|
||||
|
echo "Suppress repeated empty lines" |
||||
|
echo "-------------------------------" |
||||
|
|
||||
|
cat -s $LLO_DATAFILE | head -9 |
||||
|
echo "" |
||||
|
|
||||
|
echo "In case, you need to use the -v, -E and -T option together, you can just use the -A command line option." |
||||
|
echo "-------------------------------" |
||||
|
|
||||
|
cat -A $LLO_DATAFILE | head -9 |
||||
|
echo "" |
||||
|
|
@ -0,0 +1,4 @@ |
|||||
|
tmpfile=$(mktemp /tmp/test1.XXXXXX) |
||||
|
cat -A $LLO_DATAFILE | head -5 > $tmpfile |
||||
|
cat $tmpfile |
||||
|
|
@ -0,0 +1,8 @@ |
|||||
|
Use *mktemp* to create a temporary file in _/tmp_ |
||||
|
|
||||
|
run |
||||
|
|
||||
|
[source,bash] |
||||
|
---- |
||||
|
mktemp --help |
||||
|
---- |
File diff suppressed because it is too large
@ -0,0 +1,62 @@ |
|||||
|
The cat command also allows |
||||
|
|
||||
|
- Display tab characters as ^I |
||||
|
|
||||
|
[source,bash] |
||||
|
---- |
||||
|
display tab characters as ^I |
||||
|
---- |
||||
|
|
||||
|
For example: |
||||
|
|
||||
|
[source,bash] |
||||
|
---- |
||||
|
cat -T $LLO_DATAFILE | head -9 |
||||
|
---- |
||||
|
|
||||
|
|
||||
|
- Display non printing characters |
||||
|
|
||||
|
For example: |
||||
|
|
||||
|
[source,bash] |
||||
|
---- |
||||
|
cat -v $LLO_DATAFILE | head -9 |
||||
|
---- |
||||
|
|
||||
|
- Suppress repeated empty lines |
||||
|
|
||||
|
For example: |
||||
|
|
||||
|
[source,bash] |
||||
|
---- |
||||
|
cat -s $LLO_DATAFILE | head -9 |
||||
|
---- |
||||
|
|
||||
|
[INFO] |
||||
|
==== |
||||
|
In case, you need to use the -v, -E and -T option together, you can just use the -A command line option. |
||||
|
==== |
||||
|
|
||||
|
For example: |
||||
|
|
||||
|
[source,bash] |
||||
|
---- |
||||
|
cat -A $LLO_DATAFILE | head -9 |
||||
|
---- |
||||
|
|
||||
|
[INFO] |
||||
|
==== |
||||
|
|
||||
|
DATAFILE |
||||
|
|
||||
|
The datafile contains aggregate individual statistics for 67 NBA seasons. from basic box-score attributes such as points, assists, rebounds etc., to more advanced money-ball like features such as Value Over Replacement. |
||||
|
|
||||
|
Take a look in |
||||
|
link:https://git.swarmlab.io:3000/llo/LabLearningObject/src/branch/master/data/nba_statistics_glossary[Glossary^] |
||||
|
for a detailed column description |
||||
|
|
||||
|
ENVIRONMENT VARIABLE: LLO_DATAFILE |
||||
|
|
||||
|
==== |
||||
|
|
@ -0,0 +1,8 @@ |
|||||
|
|
||||
|
Create a temporary file and put output with |
||||
|
|
||||
|
[source,sh] |
||||
|
---- |
||||
|
cat -A $LLO_DATAFILE | head -5 > ... |
||||
|
---- |
||||
|
|
@ -0,0 +1,6 @@ |
|||||
|
*cut* command is one of the most useful & important command used in Linux. |
||||
|
|
||||
|
It is used for cutting out the sections from each line of files and writing the result to standard output. |
||||
|
|
||||
|
|
||||
|
In this *LO*, we will see the most used cat Commands examples in Linux. |
@ -0,0 +1,51 @@ |
|||||
|
--- # Programming language |
||||
|
name: "cut" |
||||
|
base_url: "https://git.swarmlab.io:3000/llo/LabLearningObject/raw/branch/master" |
||||
|
author: "zeus" |
||||
|
intro: "intro" |
||||
|
0_Display_Content: |
||||
|
display_name: "Cutting_Content" |
||||
|
swarmlabservice: "os2" |
||||
|
info: |
||||
|
file: "0_Cutting_Content/info" |
||||
|
code: |
||||
|
lang: "bash" |
||||
|
exec: "/bin/bash" |
||||
|
file: "0_Cutting_Content/code" |
||||
|
data: "0_Cutting_Content/data" |
||||
|
options: "" |
||||
|
mimetype: "bash" |
||||
|
output: |
||||
|
log: "console" |
||||
|
mimetype: "bash" |
||||
|
challenge: |
||||
|
question: "0_Cutting_Content/q-info" |
||||
|
codehelp: "0_Cutting_Content/codehelp" |
||||
|
codeanswer: "0_Cutting_Content/codeanswer" |
||||
|
mimetype: "bash" |
||||
|
points: "" # ELO |
||||
|
output: |
||||
|
log: "bash" |
||||
|
1_Advanced_Displays: |
||||
|
display_name: "Advanced_Displays" |
||||
|
swarmlabservice: "os2" |
||||
|
info: |
||||
|
file: "1_Advanced_Displays/info" |
||||
|
code: |
||||
|
lang: "bash" |
||||
|
exec: "/bin/bash" |
||||
|
file: "1_Advanced_Displays/code" |
||||
|
data: "1_Advanced_Displays/data" |
||||
|
options: "" |
||||
|
mimetype: "bash" |
||||
|
output: |
||||
|
log: "console" |
||||
|
mimetype: "bash" |
||||
|
challenge: |
||||
|
question: "1_Advanced_Displays/q-info" |
||||
|
codehelp: "1_Advanced_Displays/codehelp" |
||||
|
codeanswer: "1_Advanced_Displays/codeanswer" |
||||
|
mimetype: "bash" |
||||
|
points: "" # ELO |
||||
|
output: |
||||
|
log: "bash" |
Loading…
Reference in new issue