How to keep quotes in Bash arguments

0 votes

I have a Bash script where I want to keep quotes in the arguments passed.

Example:

./test.sh this is "some test"

then I want to use those arguments, and re-use them, including quotes and quotes around the whole argument list.

I tried using \"$@\", but that removes the quotes inside the list.

How do I accomplish this?

Jun 13, 2022 in Linux Administration by Rahul
• 3,380 points
738 views

1 answer to this question.

0 votes
utilizing "$@" will substitute the contentions as a rundown, without re-dividing them on whitespace (they were parted once when the shell script was conjured), which is by and large precisely exact thing you need on the off chance that you simply need to re-pass the contentions to another program.

Note that this is an exceptional structure and is possibly perceived thusly in the event that it shows up precisely along these lines. In the event that you add anything more in the statements the outcome will get consolidated into a solitary contention.

What are you attempting to do and how is it not functioning?
answered Jun 13, 2022 by Korak
• 5,820 points

Related Questions In Linux Administration

0 votes
1 answer

How to take input from user in bash script?

You can use if-else branch to check ...READ MORE

answered Jan 31, 2019 in Linux Administration by Omkar
• 69,210 points
868 views
0 votes
1 answer

How to extract file base name without path and extension in bash?

You don't actually have to call the ...READ MORE

answered May 31, 2019 in Linux Administration by Shubham
• 13,490 points
5,501 views
0 votes
1 answer

How to find the first field from a file in Bash Shell?

Hi@akhtar, You can extract text from a file. ...READ MORE

answered Oct 20, 2020 in Linux Administration by MD
• 95,440 points
836 views
0 votes
0 answers
0 votes
0 answers

How to split a string into an array in Bash?

In a Bash script, I would like ...READ MORE

Jun 9, 2022 in Linux Administration by Rahul
• 3,380 points
397 views
0 votes
0 answers

How to list all background pids in bash

Either I am not able to phrase ...READ MORE

Jun 22, 2022 in Linux Administration by Korak
• 5,820 points
264 views
0 votes
1 answer

How to increase Swap Memory in CentOS 7?

Follow the below steps and procedures: Prerequisites Must have ...READ MORE

answered Oct 5, 2018 in Linux Administration by Frankie
• 9,830 points
15,413 views
–1 vote
1 answer

How to get octal file permission in linux?

You can use this: stat -c "%a %n" ...READ MORE

answered Jan 3, 2019 in Linux Administration by Omkar
• 69,210 points
2,096 views
0 votes
1 answer

How to check if a string contains a substring in Bash?

You ought to recollect that shell prearranging ...READ MORE

answered May 27, 2022 in Linux Administration by Korak
• 5,820 points
864 views
0 votes
1 answer

How do I check if a directory exists in a Bash shell script?

To check if a directory exists in ...READ MORE

answered Jun 7, 2022 in Linux Administration by Korak
• 5,820 points
1,478 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP