Flashcards
Sem título
Flashcards do conjunto (6)
- 1cat > hello.txt this is writing to the file hello.txt on top of anything else that is present cat >> hello.txt now appending ctrl + d to save filels -l | tail -n1
last 1 line gets printed
$ tail –n/+n filename
– The -n option displays n lines from the end of the file.
– The +n option displays the file from line n to the end of the file. - 2sudo - is asuper user, access to all files of the system at kernel level $ cd /sys $ ls $ cd class/ $ cd backlight/ $ lsxdg-open - to open a file
it will open it to an appropriate program
xdg-open lecture.html
will open a browser - 3$ foo = bar wont work bcoz of spaces in btw diff in " " & ' ' echo "the value is $foo" o/p = the value is bar echo 'the value is $foo' o/p= the value is $foo#!/bin/bash
mcd(){
mkdir -p "$1"
cd "$1"
}
$ source mcd.sh
we need to call the function
$ mcd test
a directory created named test and cd test happened - 4$ mkdir test $ cd $_ this takes last argument from the last commandeg.
$ echo test last argument
$ cd $_
o/p argument - 5$ grep foobar mcd.sh will search for foobar in mcd.sh file .. $ echo "hello" $ echo $? o/p=0 // everything went fine so it returns 0 $ grep foobar mcd.sh echo $? o/p=1 // foobar not present// 1 indicates error or things didnt go as expected$ false || echo "oops fails"
o/p = oops fails
$ echo $?
o/p =0
$ false ; echo "hhkj"
o/p hhkj - 6$ foo = $(pwd) echo "$foo" echo "hello $(pwd)" // works echo "hello $foo" // works echo hello "$foo" //works echo hello $foo //workssee
Informações
- Descrição
- FlashCards sobre Sem título, criado por Parul Ansal em 24-08-2020.
- Criado por
- Parul Ansal
- Visualizações
- 2
- Avaliação
Mais sobre Command Line Basics and Linux Commands