No difference is there, both commands gives the same result.
If we copy the file, modified time will be changed. If we move the file there will be no change in the time.
Read also: Unix interview questions and answers part – 1
Yes we can. We need to use ‘-p’ option while copying the file.
We can use ‘uniq’ command to remove duplicates from a file. ‘uniq’ does not detect repeated lines unless they are adjacent. You may want to sort the input first, or use ‘sort -u’ without ‘uniq’.
$ sort emp_data.txt | uniq
‘uniq -d’ command is useful to display duplicates from a file.
$ sort emp_data.txt | uniq -d
We can use ‘uniq -c’ command to employee count by GROUP BY department number.
$ cut -d ',' -f2 emp_data.txt | sort | uniq -c
Read also: Unix interview questions and answers part – 2
We need to write a shell script for this requirement. This script can be customized according to your requirement.
FILE_FLG="N" cd $src_loc while [ FILE_FLG eq "N" ]; do if [ -e $src_file_nm ]; then ;# If file exists in directory FILE_FLG="Y" fi sleep 600 # loop wait for 10 minutes done
The cmp command is used mainly to compare two files byte by byte, after which the first encountered mismatch is shown. On the other hand, the diff command is used to indicate the changes that is to be made in order to make the two files identical to each other.
$ grep -orI unix . | wc -lTo list every occurrence of the term “unix” on a separate line, one must run grep -o unix <path>. Adding the ‘r’ option to the command makes the search recursively process every file under the given path, and the ‘I’ option ensures that matches in binary files are ignored. In addition, the ‘w’ option can be included to match the exact term only, and ignore superstrings such as “unixsystem”, and to make the search case-insensitive, the i flag can be added as well:
$ grep -iworI potato . | wc -l
for (( i = ${#}; i &gt; 0; i-- )); do echo ${!i} doneThe arguments are available as $<n>, where n is the position of the argument.
For example, $0 would give the name of the script, $1 would give the first additional argument, $2 the second, and so on. The total number of additional arguments is found in $#.
A loop that starts at $# and ends at 1 can be used to print each additional argument in reverse order.