Shell script to check file executable permission availability

SCRIPT:
#!/bin/bash
USAGE="usage : $0 {filename}"
CHECK_FILE=$1
if [ $# -lt 1 ]
then
 echo "$USAGE"
 exit 1
fi
if [ -x "$CHECK_FILE" ]
then
 echo "$CHECK_FILE has the executable permission"
else
 echo "$CHECK_FILE not has executable permission"
fi
OUTPUT-1:
test.sh has the executable permission

OUTPUT-2:

sujin_sr not has executable permission

C Program Lab Exercise


I. SWAPPING OF TWO NUMBERS USING FUNCTION:
Program:
#include <stdio.h>
void swap(int, int);
int main()
{
    int x, y;
    x = 10;
    y = 20;
    swap(x, y);
    printf("Value of x and y after swap(x, y) in main()  : %d %d \n", x, y);
}

void swap(int a, int b)
{
    int t;
    printf("Value of a and b before exchange in swap()   : %d %d \n", a, b);
    t = a;
    a = b;
    b = t;
    printf("Value of a and b after exchange in swap()    : %d %d \n", a, b);
    return 0;
}

Output:
Value of a and b before exchange in swap()   : 10 20
Value of a and b after exchange in swap()    : 20 10
Value of x and y after swap(x, y) in main()  : 10 20


Shell Script to reverse string


SCRIPT
#!/bin/bash
input="$1"
output=""
output=$(echo $input | rev)
echo "Input  : $input"
echo "Output : $output"

OUTPUT:
sujin@sujin:~/sujin/common/script$ bash reverse.sh linux
Input  : linux
Output : xunil