differnce between two commands

What is difference between this two commands.

info_file_name=`echo $i | cut -d "/" -f 7`
 
info_file_name=`echo $i | cut -d "/" -f 6`
sam2929Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

arnoldCommented:
The field being reported.
I.e.
/some/Pah/to/file/of/interest/as/input
The first will return input while the second will return as.

Cut parses the input data based on '/'
sam2929Author Commented:
Not sure what you said can you give an example please3
arnoldCommented:
If I='/some/Pah/to/file/of/interest/as/input'
When you run each command which parses the contents of the variable i,
The first one is interested in the 7th element which from the example will be as
The second command which is interested in the 6th element which in the anode example will be interest

Seems ihave miscounted.

The best way I find what commands do is to select the input and see what the results.

Cut -d "/" will break the string based on the existence of every '/' in the string. As a list of items separated by /




What is unclear.

It is easier to explain when your concept or understanding of the issue is included.
ssvlCommented:
info_file_name=`echo $i | cut -d "/" -f 7` - stores  the 7th Field from "/" in the given input(i) to info_file_name variable

info_file_name=`echo $i | cut -d "/" -f 6` . - stores  the 6th Field from "/" in the given input(i) to info_file_name variable

eg: -
i="/1/2/3/4/5/6/"
then your results will be
info_file_name=`echo $i | cut -d "/" -f 7` --> 6
info_file_name=`echo $i | cut -d "/" -f 6`  --> 5

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
arnoldCommented:
Unfortunately, it seems I double miscounted as the above
The first / separates field number 1 from field number 2
The second, separates field 2 from 3 etc.

If the string is 1/2/3/4/5/6/7/8
When passed through cut -d '/' -f 7 returns 7
-f 6 will return 6
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Unix OS

From novice to tech pro — start learning today.