Find Interview Questions for Top Companies
Ques:- what is the difference between sh & bash shell?
Asked In :-
Comments
Admin May 17, 2020

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.

Ques:- Please give me example of ” at command , contrab command ” how to use
Asked In :-
Ques:- how to print the matrix form of 2-d, 3-d arrays in unix c shell scripts ?
Asked In :-
Right Answer:
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
```
Ques:- RAM one table colums a1,a2,a3,a4 respective values 2,4,7,8 KRISH one table colums a1,a2,a3,a4 respective values 3,4,6,9 IN RAM & KRISH a4 column if comparing values RAM A4 – KRISH A4 ( 8-9 =1 THEN print 5 or (RAM) a4 value 10 KRISH a4 values 2 then 10 -2 =8 print 5*8=40 or diff 5 print same
Asked In :-
Comments
Admin May 17, 2020

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

Ques:- i have 2 tables 4 colums table 1 respective values a1 6, a2 8,a3 9,a4 14 & table 2 respective values a1 6, a2 8, a3 9, a4 12. if compare 2 tables 3 colums values same then 4th column values 1)Qes diff >5 then (5 * diff value ) 2)Qes diff
Asked In :-
Ques:- Hi, I want to practise Unix korn shell scripting which i learnt 2 yr bfr. plz suggest software i can use to practise.
Asked In :-
Right Answer:
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.
Comments
Admin May 17, 2020

you can use CYGWIN which can be installed on various Windows platform.

Ques:- how to separate the even and odd number generated from one file to two separate file i.e. even numbers in file1.txt and odd numbers in file2.txt
Asked In :-
Right Answer:
```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
```
Comments
Admin May 17, 2020

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

Admin May 17, 2020

echo "Enter the file name"
read file
awk '$NF % 2 == 0' $file > file1.txt
awk '$NF % 2 != 0' $file > file2.txt

Ques:- how to find weblogic version through linux cammand
Asked In :-
Right Answer:
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"
```
Comments
Admin May 17, 2020

$ java weblogic.version -verbose
(OR)
$ java weblogic.utils.Versions
(OR)
java weblogic.Admin -url ManagedHost:8001 -username weblogic
-password weblogic VERSION

Ques:- what is info area how many types?
Asked In :-
Right Answer:
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.
Ques:- write a scwipt that a) takes exactly one argument, a directory name. b) if the number of argument is more or less than one,print a usage message c) if the argument is not adirectory, print another message d) for the given directory, print the five biggest files and the five files that were most recently modified. e) save the output to a file called q2output.
Asked In :-
Right Answer:
```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
Comments
Admin May 17, 2020

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

Admin May 17, 2020

practcal withe vmware
unix

Ques:- What is the difference between running a script as ./scriptname.sh and sh scriptname.sh
Asked In :-
Right Answer:
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.
Comments
Admin May 17, 2020

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

Ques:- Set up a Sev 2 alert when the Primary WA service fails. A windows batch script needs to be created that will monitor the WA service on the Primary and when the service stops/fails a Sev 2 TT is generated for a particular team ?
Asked In :-
Right Answer:
```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
```
Ques:- what is tickets $ what low,medium,high priorite pls define time also
Asked In :-
Right Answer:
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.
Ques:- Hi All, Is it possible to create one file name only space or space in file name in UNIX and we can able to run that on Unix?
Asked In :- iOPEX,
Right Answer:
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.
Comments
Admin May 17, 2020

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

Admin May 17, 2020

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.

Ques:- In a file , how to retrieve the lines which are the multiples of 50 ? like 50,100,150th lines etc.
Asked In :-
Right Answer:
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.
Comments
Admin May 17, 2020

awk 'NR % 50 == 0' print

Admin May 17, 2020

awk 'NR % 50 ==0 {print}' filename

Ques:- if i have 2 files file1 and file2…. file1 contains 2 columns like b a 11 aa 12 as 13 ad 15 ag 11 ar 13 ah 15 ak file2 contains b c 10 ds 11 at 15 gh 15 jk 13 iu 11 fg 13 yy can any 1 give me the program to display in this way? a b c aa 11 at ar 11 fg ad 13 iu ah 13 yy ag 15 gh ak 15 jk
Asked In :-
Comments
Admin May 17, 2020

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.

Admin May 17, 2020

paste file1 file2 | cut -f 2,3,4 -d " "

Ques:- Create a bash shell script that reads a line from the user consisting of 5 words and then prints them out in reverse order. Name this script “reverse.sh”
Asked In :-
Comments
Admin May 17, 2020

read line;
echo $line | awk '{ for ( i = NF; i > 0; i--) print $i}' |
tr "n" " "

Ques:- Create a bash shell script that reads in a number from the user. If the number is 1, print out the date. If the number is 2, list the files in the current directory. If the number is 3, print out who is currently logged onto the system. If the number is anything else, print out an error message and exit. Name this script “various.sh”
Asked In :-
Comments
Admin May 17, 2020

cho "Enter Choice"
read num
case $num in
1) echo `date`
;;
2) ls
;;
3) who
;;
*) echo "Wrong option press 1 2 3 only"
;;
esac

Admin May 17, 2020

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

Ques:- Hi, all Scripting professional. Q. I have written script1.sh and calling script2.sh in script1.sh file using bash shell as interpreter and my log in shell also bash shell.My code like Script1 #!/bin/bash echo “My script2 call” . script2.sh Here script2.sh file run successfully but when I have changed my interpreter bash to ksh like #!/bin/ksh Error are comming script2.sh command not found. Guid me how to call other script in our main script.
Asked In :-
Comments
Admin May 17, 2020

write code like this :
#!/bin/bash
echo "My script2 call"
/bin/bash ./script2.sh [ or /bin/ksh ./script2.sh ]
It will run ..... enjoy !!!!!!

Admin May 17, 2020

instead of
. script2.sh
Just try
sh script2.sh
It will Run

Ques:- What are the 4 basics of OOP?
Asked In :-
Right Answer:
The four basics of OOP are:

1. Encapsulation
2. Abstraction
3. Inheritance
4. Polymorphism
Comments
Admin May 17, 2020

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.

AmbitionBox Logo

What makes Takluu valuable for interview preparation?

1 Lakh+
Companies
6 Lakh+
Interview Questions
50K+
Job Profiles
20K+
Users