Professional Documents
Culture Documents
Unix
Unix
Sed 1d filename
4) Write a command to print the fields from 10 to 20 from each line of a file?
Find . –size 0
ls -Sl
Cut –c 5- filename
11) Write a Shell Script that adds two numbers if provided as the command Line
Argument and if the two numbers are not entered, it outputs an Error Message
#!/bin/sh
A=10
B=20
Then
Else
FILE=(file path)
if [ -f "$FILE" ]; then
else
fi
3. If file path exists, create the file with file name passed as parameter
4. Write the content "Hello World" to the file
#!/bin/sh
Echo”Hello World”
13) Write the shell script that renames all files in the current directory that end in
“.jpg” to begin with today’s date in the following format: YYYY-MM-DD. For
example, if a picture of my cat was in the current directory and today was October
31,2016 it would change name from “mycat.jpg” to “2016–10–31-mycat.jpg”.
#!/bin/bash
DAY=$(date +%F)
cd /home/
do
mv $FILE ${DAY}-${FILE}
done
#!/bin/sh
Echo”man”
Echo”bear”
Echo”pig”
Echo”dog”
Echo”cat”
Echo”sheep”