function::kernel_string_quoted - Linux


function::kernel_string_quoted is a bash function used to generate a quoted string from a given string. It handles whitespace and special characters to ensure the resulting string is suitable for use in scripts or shell commands.


function kernel_string_quoted() { local n=$1; echo -ne "\"$n\"" ; }


This function has no options or flags.


  • Quoting a string with spaces:
kernel_string_quoted "my string with spaces"
# Output: "my string with spaces"
  • Quoting a string with special characters:
kernel_string_quoted "my string \"with special characters\""
# Output: "my string \"with special characters\""
  • Using the quoted string as an argument for another command:
echo $(kernel_string_quoted "my string with spaces")
# Output: my string with spaces

Common Issues

None known.


This function can be integrated with other Linux commands or tools to handle strings in a reliable and consistent manner. For example, it can be used to quote arguments for commands that expect a single quoted string.

Related Commands

  • echo: Outputs a string to the console.