21. Advanced List Handling with `case`Write a script that uses an array to store a list of valid usernames. Take a username as input and use a `case` statement to check if the input username is in th…
20. Nested `case` StatementsWrite a script that takes a user input for a day and time (morning, afternoon, evening) and prints a specific message for each combination using nested `case` statements.
19. Handling Multiple Values in `case`Write a script that takes a command-line argument and prints whether it is a start, stop, or restart command using a `case` statement. If the argument is none of…
18. Pattern Matching with Wildcards using `case`Write a script that takes a filename as input and checks if the file is a text file (*.txt), image file (*.jpg, *.png), or an unknown type using a `cas…
16. Using `[[ ]]` for Complex ConditionsWrite a script that takes a string as input and checks if the string starts with "A" and ends with "Z". Use `[[ ]]` for the condition.
14. Combining String and Number ComparisonsWrite a script that takes a username and age as input. Check if the username is not empty and the age is greater than 18. Print an appropriate message.
13. Number ComparisonWrite a script that takes two numbers as input and checks if the first number is greater than, less than, or equal to the second number.
11. Understanding Exit CodesWrite a script that attempts to create a directory. Check the exit code of the `mkdir` command and print whether the directory was created successfully or not.
10. Combining Conditions with Logical OperatorsWrite a script that takes two numbers as input and checks if both numbers are positive using logical AND. Print an appropriate message.
int main()
{
char ch;
do
{
printf("Hello world\n");
printf("Do you want to print it again?Enter y for yes/n for no.\n");
scanf("%c",&ch);
}while(ch=='y');
…
11. Bidirectional Communication with ReversalWrite a program where the parent sends a string to the child, the child reverses the string, and sends it back to the parent. The parent then prints the r…
4. Bidirectional CommunicationExtend the program to create two pipes: one for parent-to-child communication and another for child-to-parent communication. The parent sends a message to the child, the…
8. Reading and Writing StringsWrite a program where the parent process reads a string from the user, writes it to the pipe, and the child process reads the string from the pipe and prints it.
3. Parent to Child CommunicationWrite a program where the parent process writes a message to the pipe, and the child process reads the message from the pipe and prints it.
10. Multiple Writes and ReadsImplement a program where the parent process writes multiple messages to the pipe and the child process reads and prints each message.
1. Dynamic String Manipulation and FormattingWrite a Bash script that accepts a full name from the user (in the format "First Middle Last") and then formats it into "Last, First Middle…
2. Multi-level String Length ValidationWrite a Bash script that reads a string from the user and classifies it into three categories: "Short string" if less than 5 characters, "Medium …
3. Advanced Substring ManipulationWrite a Bash script that extracts the username and domain name from an email address, then creates a new email address by reversing the domain and username (e.g., `u…
4. Recursive String ReplacementWrite a Bash script that performs recursive replacement of the word "foo" with "bar" in a given string until no more "foo" can be found. P…
5. Case-Insensitive Substring ReplacementWrite a Bash script that reads a string and replaces all occurrences of the word "hello" (case insensitive) with "hi". Ensure the replacem…
6. Splitting Strings and Counting ElementsWrite a Bash script that splits a colon-separated string into an array and prints each element on a new line. Additionally, count the number of elements and …
7. Extracting Components from a URLWrite a Bash script that extracts the protocol, domain, and path from a given URL. Print each component separately.→ Expected Output Example:Enter a URL: https://ex…
8. Advanced String Padding and AlignmentWrite a Bash script that reads a string and right-pads it with dots (.) to ensure it is at least 20 characters long. If the string is already 20 characters or …
9. String Reversal with Special Character HandlingWrite a Bash script that reads a string and reverses it, ensuring that any special characters (non-alphanumeric) remain in their original positions.→…
10. Character Frequency AnalysisWrite a Bash script that reads a string and outputs the frequency of each character in the string. Print the characters and their frequencies in descending order of fr…
7. Recursion in FunctionsWrite a Bash script that defines a recursive function named `factorial` which calculates the factorial of a given number. The function should take a single parameter (the num…
8. Function with Multiple Return ValuesCreate a Bash script with a function named `get_user_info` that takes a username as a parameter and returns the user's ID and home directory. Capture the r…
9. Using `shift` to Process All Positional ParametersWrite a Bash script with a function named `process_args` that processes all positional parameters passed to it and prints each one. Use the `shift…
11. Overview and Syntax of sigactionWhat is the sigaction function and how does it provide more control over signal handling compared to the signal function? Describe its syntax and the purpose of it…
10. Practical Example of Signal BlockingWalk through the example program that blocks the SIGINT signal for 10 seconds and then unblocks it. Explain the steps involved in setting up the signal handler…
9. Blocking Signals in Critical SectionsWhy is it important to block signals in critical sections of code? Provide an example of how to block SIGINT during a critical section to ensure the integrity …
8. Using sigprocmask for Signal BlockingExplain the purpose of the sigprocmask function in Unix-like operating systems. Describe its syntax and how it can be used to block and unblock signals, provid…
7. Critical Section and Pending SignalsExplain the concept of a critical section in the context of signal handling. How does the example program ensure that SIGINT is not delivered during the critica…
6. Example of Inspecting Pending SignalsDescribe the steps involved in the example program that inspects pending signals using sigpending. How does the program block SIGINT, check if it is pending, a…
5. Purpose and Usage of sigpendingWhat is the purpose of the sigpending function in Linux, and how is it used? Provide a brief explanation and describe its syntax.
4. Manipulating Signal SetsDiscuss the functions sigemptyset, sigfillset, sigaddset, sigdelset, and sigismember used for manipulating signal sets in Linux. Provide examples demonstrating the initiali…
3. Checking Pending SignalsExplain how the sigpending function is used to examine pending signals in a process. Provide an example that checks if SIGINT is pending and prints a message accordingly.
2. Understanding sigprocmaskDescribe the purpose of the sigprocmask function in Linux signal handling. Explain the different ways it can modify the signal mask and provide an example of its usage to …
1. Signal Management in the KernelExplain the process by which the Linux kernel handles a blocked signal from arrival to unblocking. Include in your explanation the roles of sigset_t, sigpending, and…
20. Kernel Data Structures for Managing SignalsDescribe the key signal-related fields within the task_struct in Linux. How does the kernel use these fields to manage pending signals?
19. Understanding Pending SignalsWhat are pending signals in Linux, and how do they become pending? Explain the concept and scenarios under which signals are marked as pending.
18. Using the SA_SIGINFO FlagWhat is the SA_SIGINFO flag in the sigaction structure, and how does it modify the behavior of signal handling? Provide an example that demonstrates using SA_SIGINFO to h…
17. Setting Up Signal Handlers with sigactionExplain how to set up a signal handler using the sigaction function. Provide an example of setting up a handler for the SIGINT signal that blocks the SIGT…
16. Understanding struct sigactionDescribe the purpose of the struct sigaction in Linux signal handling. What fields does this structure contain, and what are their roles?
15. Using SA_SIGINFO for Extended Signal InformationDescribe the purpose of the SA_SIGINFO flag in the sigaction structure. Provide an example of using SA_SIGINFO to handle the SIGINT signal and acce…
14. Blocking Signals During Handler ExecutionExplain how to block signals during the execution of a signal handler using the sigaction structure. Provide an example of blocking SIGTERM while handling…
13. Understanding sigactionWhat is the sigaction function and how does it provide more robust and flexible signal handling compared to the signal() function? Describe the structure and key fields of …
12. Ignoring and Restoring Default Signal HandlingDescribe how to ignore a signal in a C program using the signal() function. Additionally, explain how to restore the default action for a signal afte…
11. Characteristics and Best Practices of Signal HandlersWhat are the key characteristics of signal handlers in Linux? Discuss the concepts of asynchronous execution, reentrancy, and atomic operation…
10. Defining and Using Signal HandlersExplain how to define and set up a signal handler in C using the signal() function. Provide an example of handling the SIGINT signal and describe what happens wh…
9. Catching Signals with Custom HandlersWhat does catching a signal mean in the context of signal handling in Linux? Illustrate with an example how to catch the SIGINT signal using a custom signal ha…
8. Ignoring SignalsExplain how a process can ignore a signal in Linux. Provide an example of how to ignore the SIGINT signal using the signal() function.
7. Default Actions of SignalsDescribe the default actions associated with signals in Linux. What are some common default actions that a signal can trigger if no custom signal handler is set up?
6. Practical Signal Handling with signal() FunctionDescribe how the signal() function works in setting up a signal handler in a C program. Provide a brief example of how to use signal() to catch the …
5. Common Signals and Their EffectsList at least five common signals defined in the signal.h header file and describe their typical use or effect on a process. How does the system handle these signal…
4. Understanding Signal Generation and HandlingExplain the terms "raise" and "catch" in the context of signal handling in UNIX and Linux systems. What are some common conditions t…
3. Signal HandlingDescribe how a process can handle signals in Linux. What are the possible actions a process can take when a signal is delivered, and how can a signal handler function be set up usin…
2. Signal Characteristics and TypesExplain the characteristics of signals in Linux. What are the two broad categories of signals, and provide examples of each.
1. Understanding SignalsWhat are signals in the context of Linux and UNIX-like operating systems, and how do they function as a form of inter-process communication?