WUT_Computer_Science/Programming/EOPSY/lab1/modify_examples.sh

89 lines
2.6 KiB
Bash
Raw Normal View History

2022-04-08 05:03:49 +02:00
#!/bin/bash
touch a
touch B
touch SED
mkdir foldera
mkdir FOLDERB
mkdir FOLDERSED
mkdir upperfoldermain
cd upperfoldermain
touch upperfilesub
mkdir upperfoldersub
cd upperfoldersub
touch upperfilesubsub
cd ..
cd ..
mkdir LOWERCASEFOLDERMAIN
cd LOWERCASEFOLDERMAIN
touch LOWERFILESUB
mkdir LOWERFOLDERSUB
cd LOWERFOLDERSUB
touch LOWERFILESUBSUB
cd ..
cd ..
mkdir SEDLOWERCASEFOLDERMAIN
cd SEDLOWERCASEFOLDERMAIN
touch SEDLOWERFILESUB
mkdir SEDLOWERFOLDERSUB
cd SEDLOWERFOLDERSUB
touch SEDLOWERFILESUBSUB
cd ..
cd ..
touch recursefile
touch RECURSELOWERFILE
touch SEDRECURSEFILE
echo "Typical scenarios"
echo "Uppercasing file with filename a"
2022-04-08 05:17:55 +02:00
bash ./modify.sh -u a
2022-04-08 05:03:49 +02:00
echo "Lowercasing file with filename B"
2022-04-08 05:17:55 +02:00
bash ./modify.sh -l B
2022-04-08 05:03:49 +02:00
echo "Using sed pattern for lowercasing of file with filename SED"
2022-04-08 05:17:55 +02:00
bash ./modify.sh "-r -e s/.*/\L&/" SED
2022-04-08 05:03:49 +02:00
echo "Uppercasing folder with name foldera non recursively"
2022-04-08 05:17:55 +02:00
bash ./modify.sh -u foldera
2022-04-08 05:03:49 +02:00
echo "Lowercasing folder with name FOLDERB non recursively"
2022-04-08 05:17:55 +02:00
bash ./modify.sh -l FOLDERB
2022-04-08 05:03:49 +02:00
echo "Using sed pattern for lowercasing of folder with name FOLDERSED non recursively"
2022-04-08 05:17:55 +02:00
bash ./modify.sh "-l -e s/.*/\L&/" FOLDERSED
2022-04-08 05:03:49 +02:00
echo "Uppercasing folder recursively"
echo "Main folder name: upperfoldermain"
echo "folder contains: folder named upperfoldersub , file named upperfilesub"
echo "subfolder upperfoldersub contains file named upperfilesubsub"
2022-04-08 05:17:55 +02:00
bash ./modify.sh -r -u upperfoldermain
2022-04-08 05:03:49 +02:00
echo "Lowercasing folder recursively"
echo "Main folder name: LOWERFOLDERMAIN"
echo "folder contains: folder named LOWERFOLDERSUB , file named LOWERFILESUB"
echo "subfolder LOWERFOLDERSUB contains file named LOWERFILESUBSUB"
2022-04-08 05:20:57 +02:00
bash ./modify.sh -r -l SEDLOWERCASEFOLDERMAIN
2022-04-08 05:03:49 +02:00
echo "using sed pattern for Lowercasing folder recursively"
echo "Main folder name: SEDLOWERFOLDERMAIN"
echo "folder contains: folder named SEDLOWERFOLDERSUB , file named SEDLOWERFILESUB"
echo "subfolder SEDLOWERFOLDERSUB contains file named SEDLOWERFILESUBSUB"
2022-04-08 05:17:55 +02:00
bash ./modify.sh -r "-r -e s/.*/\L&/" SEDLOWERFOLDERMAIN
2022-04-08 05:03:49 +02:00
echo "Uncommon scenarios"
echo "uppercasing recursively normal file recursefile"
2022-04-08 05:17:55 +02:00
bash ./modify.sh -r -u recursefile
2022-04-08 05:03:49 +02:00
echo "lowercasing recursively normal file RECURSELOWERFILE"
2022-04-08 05:17:55 +02:00
bash ./modify.sh -r -l RECURSELOWERFILE
2022-04-08 05:03:49 +02:00
echo "using sed pattern recursively for normal file to lowercase it SEDRECURSEFILE"
2022-04-08 05:17:55 +02:00
bash ./modify.sh -r "-r -e s/.*/\L&/" SEDRECURSEFILE
2022-04-08 05:03:49 +02:00
echo "Incorrect scenarios"
echo "not providing enough arguments"
2022-04-08 05:17:55 +02:00
bash ./modify.sh
2022-04-08 05:03:49 +02:00
echo "not providing file"
2022-04-08 05:17:55 +02:00
bash ./modify.sh -l
2022-04-08 05:03:49 +02:00
echo "not providing argument for recursion"
2022-04-08 05:17:55 +02:00
bash ./modify.sh -r filename
2022-04-08 05:03:49 +02:00
echo "provding filename/foldername for file/folder which does not exist"
2022-04-08 05:17:55 +02:00
bash ./modify.sh -l thisfiledoesnotexist
2022-04-08 05:03:49 +02:00