Not sure if this is possible, but I'm trying to read in a variable that needs to have its escape backslashes intact. So the person who enters the actual value does not have to type any \ characters. Example:
In this case the \ needs to be entered by the person who is prompted to enter input. Is there a way to preformat the read so that the \ can be inserted after the fifth character, and then a space created? Or does the person doing the input just have to remember to enter it each time?
Hi!
I've just started learning shell scripting, and have been somewhat 'thrown in at the deep-end and told to swim' so excuse my complete lack of knowledge and ignorance, but here goes...
I've been given a unix script to 'tidy up'. Basically the script consists of the few lines of code being... (2 Replies)
Hi All,
I'll get a file whose 2nd line contains 3 fields: filename(variable length), file size char(10), and record count int(10). How do I cut it and put it into 3 variables?
eg: abcd.csv01234567891111111111
now I want: $one = abcd.csv, $two = 0123456789, $three = 1111111111.
I also... (8 Replies)
Greetings all,
I'm currently making use of the $HOME/.ssh/rc file to launch an automated shell script immediately after the user has been verified through ssh.
The current problem that I'm facing now is that I am unable to use the "read" command anymore... seems like the "read" statements are... (0 Replies)
I would like to make a script to read three variables (no fixed length or position) from a line and write them into a file, with fixed length and right-justified in each column. The fixed text (text1-text4) prior to the thee variables and the variables themselves are originally separated by spaces... (3 Replies)
If I set a variable within a while-read loop, sometimes it's local to the loop, sometimes it's global, depending on how the loop is set up. I'm testing this on a Debian Lenny system using both bash and dash with the same results.
For example:
# Pipe command into while-read loop
count=
ls -1... (2 Replies)
Hello All
i have input files contains 2 values as following
20-Oct-09 Z59408009
20-Oct-09 Z59423060
and i am using the following script
cat /home/or/input.txt | awk '{print $2}' >log
count=0
while read line; do
count=$(( count + 1 ))
echo "UPDATE SAT_JRLTRT SET AVT='X' WHERE... (6 Replies)
Hi,
I want to read the variables and the values from the txt file and compare these values with the ones computed by script.
for ex:
say var.txt contains the variable names and their values:
one 1
two 2
three 3
The value of variables "one" "two" and "three" will be computed in the script... (3 Replies)
Hi
I want to read variables from one file and then set it as environment variable;
The text file is test.txt which contains
SPEED:1000
IP:172.26.126.11
My code is:
while read line; do
var1=`echo $line | awk 'BEGIN {FS=":"} { print $1 }'`
echo $var1
var2=`echo $line | awk 'BEGIN {FS=":"}... (8 Replies)
Heyas
Figured me had a 'typo' in tui-conf-set, i went to fix it.
Now, i also figured, it might be nice to have tui-conf-set report (to console, not only exit code) wether it could save the variable to the file or not.
This said, I appended this code: (the tui-title and tui-echo lines are... (3 Replies)
Discussion started by: sea
3 Replies
LEARN ABOUT SUNOS
systemd-escape
SYSTEMD-ESCAPE(1) systemd-escape SYSTEMD-ESCAPE(1)NAME
systemd-escape - Escape strings for usage in systemd unit names
SYNOPSIS
systemd-escape [OPTIONS...] [STRING...]
DESCRIPTION
systemd-escape may be used to escape strings for inclusion in systemd unit names. The command may be used to escape and to undo escaping of
strings.
The command takes any number of strings on the command line, and will process them individually, one after another. It will output them
separated by spaces to stdout.
By default, this command will escape the strings passed, unless --unescape is passed which results in the inverse operation being applied.
If --mangle is given, a special mode of escaping is applied instead, which assumes the string is already escaped but will escape everything
that appears obviously non-escaped.
For details on the escaping and unescaping algorithms see the relevant section in systemd.unit(5).
OPTIONS
The following options are understood:
--suffix=
Appends the specified unit type suffix to the escaped string. Takes one of the unit types supported by systemd, such as "service" or
"mount". May not be used in conjunction with --template=, --unescape or --mangle.
--template=
Inserts the escaped strings in a unit name template. Takes a unit name template such as foobar@.service. May not be used in conjunction
with --suffix=, --unescape or --mangle.
--path, -p
When escaping or unescaping a string, assume it refers to a file system path. This eliminates leading, trailing or duplicate "/"
characters and rejects "." and ".." path components. This is particularly useful for generating strings suitable for unescaping with
the "%f" specifier in unit files, see systemd.unit(5).
--unescape
Instead of escaping the specified strings, undo the escaping, reversing the operation. May not be used in conjunction with --suffix=,
--template= or --mangle.
--mangle
Like --escape, but only escape characters that are obviously not escaped yet, and possibly automatically append an appropriate unit
type suffix to the string. May not be used in conjunction with --suffix=, --template= or --unescape.
-h, --help
Print a short help text and exit.
--version
Print a short version string and exit.
EXAMPLES
To escape a single string:
$ systemd-escape 'Hallochen, Meister'
Hallxc3xb6chenx2cx20Meister
To undo escaping on a single string:
$ systemd-escape -u 'Hallxc3xb6chenx2cx20Meister'
Hallochen, Meister
To generate the mount unit for a path:
$ systemd-escape -p --suffix=mount "/tmp//waldi/foobar/"
tmp-waldi-foobar.mount
To generate instance names of three strings:
$ systemd-escape --template=systemd-nspawn@.service 'My Container 1' 'containerb' 'container/III'
systemd-nspawn@Myx20Containerx201.service systemd-nspawn@containerb.service systemd-nspawn@container-III.service
EXIT STATUS
On success, 0 is returned, a non-zero failure code otherwise.
SEE ALSO systemd(1), systemd.unit(5), systemctl(1)systemd 237SYSTEMD-ESCAPE(1)