SH refers to Bourne Shell, which is someway the reference Shell to a lot of other Shells, and defintaly to the Bash Shell, which literally is : Bourne Again Shell. By this time and date (2015), Bash is to be preferred over Bourne, and Bourne is supposed to be limited too much ... but, still used a lot. Obviously, in a technical way, there's a lot of interesting commands that work only with Bash, not with Bourne (and presumingly, never the other way round). So, bottom line : Bourne is limited but very compatible, Bash is better but slightly limited. The latter largely depends on environments.
To print a 2-D array in a C shell script, you can use nested loops. Here's an example for a 2-D array:
```csh
set array = ( (1 2 3) (4 5 6) (7 8 9) )
foreach i (0 1 2)
foreach j (0 1 2)
echo -n "$array[$i][$j] "
end
echo ""
end
```
For a 3-D array, you can extend the concept similarly:
```csh
set array = ( ( (1 2) (3 4) ) ( (5 6) (7 8) ) )
foreach i (0 1)
foreach j (0 1)
foreach k (0 1)
echo -n "$array[$i][$j][$k] "
end
echo ""
end
echo ""
end
```
x=`cut -f4 ram.txt`
y=`cut -f5 krish.txt`
z=`expr x-y`
if (z==5)
then echo 5
else
w= `expr 5*z`
echo $w
fi
You can use any Unix-like operating system such as Linux or macOS. Alternatively, you can install Cygwin or use a virtual machine with a Linux distribution. For practicing Korn shell scripting specifically, you can also install the Korn shell (ksh) on these systems.
you can use CYGWIN which can be installed on various Windows platform.
```bash
#!/bin/bash
# Read numbers from input file (numbers.txt)
while read -r number; do
if (( number % 2 == 0 )); then
echo "$number" >> file1.txt # Even numbers to file1.txt
else
echo "$number" >> file2.txt # Odd numbers to file2.txt
fi
done < numbers.txt
```
echo enter filename
read file
for n in `cat $file`
do
i=`expr $n % 2`
if [ $i -eq 0 ]
then
echo $n>>even.txt
else
echo $n>>odd.txt
fi
done
echo "Enter the file name"
read file
awk '$NF % 2 == 0' $file > file1.txt
awk '$NF % 2 != 0' $file > file2.txt
You can find the WebLogic version by running the following command in the terminal:
```bash
$ cd /path/to/weblogic/server/bin
$ ./startWebLogic.sh -version
```
Alternatively, you can check the version in the `release notes` file:
```bash
$ cat /path/to/weblogic/server/lib/weblogic.jar | grep "WebLogic Server"
```
$ java weblogic.version -verbose
(OR)
$ java weblogic.utils.Versions
(OR)
java weblogic.Admin -url ManagedHost:8001 -username weblogic
-password weblogic VERSION
An info area is a logical grouping of related data in a database or data warehouse. There are typically two types of info areas:
1. **Standard Info Areas** - These contain predefined data structures and are used for general reporting.
2. **Custom Info Areas** - These are user-defined and can be tailored to specific reporting needs.
```bash
#!/bin/bash
# Check if exactly one argument is provided
if [ "$#" -ne 1 ]; then
echo "Usage: $0 <directory>"
exit 1
fi
# Check if the argument is a directory
if [ ! -d "$1" ]; then
echo "$1 is not a directory."
exit 1
fi
# Output file
output_file="q2output"
# Find the five biggest files
echo "Five biggest files:" > "$output_file"
find "$1" -type f -exec du -h {} + | sort -rh | head -n 5 >> "$output_file"
# Find the five most recently modified files
echo -e "nFive most recently modified files:" >> "$output_file"
find "$1" -type f -printf '%T@ %pn' | sort -n | tail -n 5 | awk '{print $2}' >> "$output_file
for var in `ls -1S` === -S sort the file primary key as
size of the file and -1 column o/p
do
if [[ $i -eq 5 ]]
then
break;
fi
print $var
let i=i+1;
done
Same code can be used for time and ls command option will be
ls -1t
practcal withe vmware
unix
Running a script as `./scriptname.sh` executes it using the shebang line specified at the top of the script (e.g., `#!/bin/bash`), while `sh scriptname.sh` runs the script using the `sh` shell, which may not be the same as the shell specified in the shebang.
while running the script using this "./" script run from
curent location we have to give executable permision to the
script file
By default file contains 644 permissions there is no
execute permission while running it shows error
use `chmod` to give execute permission and run
where as "sh" it runs the script with the help of default
shell
```batch
@echo off
:loop
sc query "WA" | find "STATE" | find "RUNNING"
if errorlevel 1 (
echo "WA service is down. Generating Sev 2 alert..."
REM Command to generate Sev 2 ticket (replace with actual command)
call generate_ticket.bat "Sev 2 alert: WA service is down"
)
timeout /5
goto loop
```
In the context of project management and issue tracking, "tickets" refer to individual records of issues, tasks, or requests that need to be addressed. They are often prioritized based on their urgency and impact:
- **Low Priority**: Issues that are not urgent and can be addressed later. They typically have a longer resolution time, often days or weeks.
- **Medium Priority**: Issues that need attention but are not critical. They usually have a moderate resolution time, often within a few days.
- **High Priority**: Critical issues that need immediate attention. They typically require resolution within hours or the same day.
No, it is not possible to create a file with only a space as its name in UNIX. However, you can create a file with spaces in its name, but it must have at least one non-space character.
Yes..:)
just open unix prompt
vi " " or vi "ab cd"
echo "jagadeeb"
:wq
just give permission :)like
chmod 777 " " or chmod 777 "ab cd"
and run that like
./" " or ./"ab cd"
out put like
jagadeeb
jagadeeb@gmail.com
Unix-legitimate filenames are any combination of these
three classes of characters: Upper and lower case letters:
A - Z and a - z
Numbers 0 - 9
Periods, underscores, hyphens . _ -
Note that line spaces (aka "whitespace") are not allowed in
filenames. The Unix shell will think you mean more than one
file.
You can use the following command in a shell script to retrieve lines that are multiples of 50 from a file:
```bash
awk 'NR % 50 == 0' filename
```
Replace `filename` with the name of your file.
awk 'NR % 50 == 0' print
awk 'NR % 50 ==0 {print}' filename
Sorry Sudhir,
Your syntax is wrong.It should be
paste file1 file2|cut -d " " -f2,3,4
But this command is n't providing the correct result.
Piz try another.
paste file1 file2 | cut -f 2,3,4 -d " "
read line;
echo $line | awk '{ for ( i = NF; i > 0; i--) print $i}' |
tr "n" " "
cho "Enter Choice"
read num
case $num in
1) echo `date`
;;
2) ls
;;
3) who
;;
*) echo "Wrong option press 1 2 3 only"
;;
esac
echo "Enter the number"
read i
if [ $i -eq 1 ];then
echo `date`
elif [ $i -eq 2 ];then
ls
elif [ $i -eq 3 ];then
who
else
echo "Nothing"
fi
write code like this :
#!/bin/bash
echo "My script2 call"
/bin/bash ./script2.sh [ or /bin/ksh ./script2.sh ]
It will run ..... enjoy !!!!!!
instead of
. script2.sh
Just try
sh script2.sh
It will Run
The four basics of OOP are:
1. Encapsulation
2. Abstraction
3. Inheritance
4. Polymorphism
1.Data Abstraction
2.Data Encapsulation
3.Polymorphism
4.Inheritance
Welcome to the Shell Script category on takluu.com, designed for professionals and beginners preparing for roles in system administration, DevOps, and automation testing.
Shell scripting is a powerful tool that automates repetitive tasks in Unix/Linux environments, making it essential for efficient system management. This category covers fundamental and advanced topics including:
-
Basics of shell scripting syntax
-
Variables, loops, and conditional statements
-
File handling and input/output operations
-
Process management and job control
-
String manipulation and regular expressions
-
Debugging shell scripts
-
Automation of system tasks and cron jobs
Common interview questions include:
-
How do you create and execute a shell script?
-
Explain different types of shell in Unix/Linux.
-
How to use loops and conditionals in shell scripts?
-
What are some common shell commands used in scripting?
-
How can you schedule a script using cron?
Our content is crafted to help you understand concepts clearly with practical examples and real-world scenarios. Whether you’re interviewing for a Linux Administrator, DevOps Engineer, or Automation Tester role, mastering shell scripting will give you a competitive edge.
At takluu.com, we update our questions regularly to reflect industry demands and evolving technologies.
Start practicing today and automate your way to success with takluu.com.