Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

Execute Bash Shell Online

echo "The last modified file is"
ls -t | head -1

Q5 gpg

#!/bin/bash
# The script assumes that the passwords are stored in a file called 'dict'
# Note that after gpg executes you can check the result using the return code variable $?
cat words1.txt | while read PASS; do

    #  --batch  Represents input using the command line
    res=$(gpg --batch --passphrase $PASS -d secret.txt.gpg 2>/dev/null)
    
    if [ 0 -eq $? ] # if the return value is 0, then no error
    then
        echo YAY found secet! $res
        exit
    fi
done

Execute Bash Shell Online

# Hello World Program in Bash Shell
echo $#
echo "Hello World!"

greatest of three numbers

# Hello World Program in Bash Shell
a=10
b=20
c=30
if [ $a -gt $b ]
then
if [ $a -gt $c ]
then
echo "$a is maximum"
else 
echo "$c is maximum"
fi
else
if [ $b -gt $c ]
then
echo "$b is maximum"
else
echo "$c is maximum"
fi
fi









arg foo 0.02

# Hello World Program in Bash Shell
demo1(){
    echo "\$1: ${1}, \$2: ${2}"
}
demo2(){
  echo $1 | sed "s/.*\?s\([0-9]\+\)e\([0-9]\+\).*/S\1E\2.$2/i"
}
demo3(){
  local input=$1
  local ext=$2
  local pattern=".*\?s\([0-9]\+\)e\([0-9]\+\).*"
  echo $input | sed "s/${pattern}/S\1E\2.${ext}/i"
}



if [ -z "$1" ]; then
  bash -f $0 irgendetwasblabla-S01E01-blabla.srt mp4
  exit 0
fi
echo "\$1: ${1}, \$2: ${2}"
demo1 "bar" "foo"
demo2 $1 $2
demo3 $1 $2
echo "\$1: ${1}, \$2: ${2}"

arg foo 0.01

# Hello World Program in Bash Shell
demo1(){
    echo "\$1: ${1}, \$2: ${2}"
}
demo2(){
  echo $1 | sed "s/.*\?s\([0-9]\+\)e\([0-9]\+\).*/S\1E\2.$2/i"
}
demo3(){
  input=$1
  ext=$2
  pattern=".*\?s\([0-9]\+\)e\([0-9]\+\).*"
  echo $input | sed "s/${pattern}/S\1E\2.${ext}/i"
}



if [ -z "$1" ]; then
  bash -f $0 irgendetwasblabla-S01E01-blabla.srt mp4
  exit 0
fi
echo "\$1: ${1}, \$2: ${2}"
demo1 "bar" "foo"
demo2 $1 $2
demo3 $1 $2
echo "\$1: ${1}, \$2: ${2}"

argument

def get_parser():
    parser = argparse.ArgumentParser(description='scanless, public port scan scrapper')
    parser.add_argument('-v', '--version', help='display the current version',
                        action='store_true')
    parser.add_argument('-t', '--target', help='ip or domain to scan',
                        type=str)
    parser.add_argument('-s', '--scanner', help='scanner to use (default: hackertarget)',
                        type=str, default='hackertarget')
    parser.add_argument('-r', '--random', help='use a random scanner',
                        action='store_true')
    parser.add_argument('-l', '--list', help='list scanners',
                        action='store_true')
    parser.add_argument('-a', '--all', help='use all the scanners',
                        action='store_true')
return parser

sheel_test

u=pwd
echo "enter the host::"
read h
su
system77
cd /home/$h
ls
echo "enter filename ::"
read f
cp $f $u
cat $u

1 Practical - (4 March 19)

# Hello World Program in Bash Shell

echo "Hello World!"

date
cal
free
df
free
ls
mkdir Sandy
ls
cd
pwd
cd Sandy
mkdir Folder_One
cd
pwd

mkdir MarleySucks
ls
mkdir Playground
ls
cd Playground

ls
mkdir dir1





Execute Bash Shell Online

# Test of STDIN input conversion

declare -a inputValues
function deleteEndLine {
   local size=${#1}
   let size-=1
   local final=${1:0:$size}
   echo "$final"
}

function readAllInputVariables {
   read endInput
   while [ "$endInput" != "ENDOFINPUT" ]
   do
      endInput="$(deleteEndLine $endInput)"
      inputValues+=($endInput)
      read endInput
   done
}

function baseSum {
   local basicSum=0
   if [$1 -eq 1];
   then
      basicSum=1
      echo "$basicSum"
   else
      local nextValue
      let nextValue=$1-1
      let basicSum=$1+"$(baseSum $nextValue)"
      echo "$basicSum"
   fi
}

readAllInputVariables
echo "ESTOY AQUIIIII"
finalSum="$(baseSum ${inputValues[0]})"
echo "$finalSum"

Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.