McAfee Interview Question for SDETs


Country: India
Interview Type: Written Test




Comment hidden because of low score. Click to expand.
0
of 0 vote

#!/usr/bin/env bash

counter=0
for i in *; do
    mv "${i}" file${count}.`echo "${i}" | awk -F. '{print $2}'`
    ((++counter))
done

for-loop:
iterating over the output of the command 'ls' command, which is alphabetically sorted.
Rest of the code is self explanatory...

- R@M3$H.N January 22, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

ls -lrt | awk '{print $9}' > temp


for i in `cat temp`
do
mv $i $i.txt
done

- Mangesh July 10, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

#!/usr/bin/ksh

echo "Toggling the names of the files - "

if [ -f *.dat ]
    then
    ls -ltr *.dat
    for i in *.dat
    do
    fname=`basename $i .dat`
    mv $i $fname".txt"
    done
    exit 0
fi

if [ -f *.txt ]
    then
    ls -ltr *.txt
    for i in *.txt
    do
    fname=`basename $i .txt`
    mv $i $fname".dat"
    done
    exit 0
fi

- ishaan.guliani September 16, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

If we need to rename all csv files to txt

ls *.csv |awk -F".csv" '{system("mv "$0" "$1".txt")}'

or

ls *.csv |awk -F".csv" '{print "mv "$0" "$1".txt"}' |sh

- Kiran Chouke January 26, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

find -type f -name <> -exec {} {}<name u like> \;
find -type f -name <> -exec rename {} {}<name u like> \;

- Pankaj December 14, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

#Don't execute on your system
find . -type f -name "a[1-9].txt" > a
count=0
c=1
for i in `cat a`
do
echo $i$count
count=$((count + c))
#mv $i $i$count ##uncomment this line when you are executing on test
done

- Sandeep April 29, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

for a in *; do mv $a $a.pdf; done

- Krishna veni August 12, 2018 | Flag Reply


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More