Tuesday, 26 April 2016

UNIX Interview Question

1. Listing files
>ls
add.sh
logfile.txt
prime.pl
2. Displaying the contents of a file.
>cat file.txt
This is a sample unix file
Learning about unix server is awesome

3. Displaying first few lines from a file.
>head -5 logfile.dat
4. Creating a file.
touch new_file.txt
7. copying the contents of one file into another.
>cp file1 file2
8. Renaming and moving the files.
Renaming file
>mv file.txt new_file.txt
 
Moving the file to another directory.
>mv new_file.txt tmp/
 





9. Finding the number of lines in a file
>wc logfile.txt
21  26 198 logfile.txt

10. Replace text with Awk command
>cat file.txt
Learn unix
Learn linux
 
 
awk '{if($2=="unix") {$2="fedora"} print $0}' file.txt
 
Learn fedora
Learn linux

11. how to  print the date on the terminal?
>date
Mon Jan 23 01:37:51 PST 2012

12. Write a unix/linux date command to print the date in GMT/UTC time zone?
>date -u
Mon Jan 23 09:40:21 UTC 2012

13. Write a unix/linux date command to display only the date part and ignore the time part?

 >date '+%m-%d-%Y'
01-23-2012

1 comment:

  1. Thank you for such useful insights. Visit here for more on advanced tech courses TALEND BIG DATA TRAINING

    ReplyDelete