If parameter $1 contains literal \\n then you can use sed to convert to a space
The \ and \n are really special. Some explanations:
I used ' ' because the shell treats \ literally in them - in contrast to " ".
I used $( ) because the shell does not mistreat \ in them - in contrast to ` `.
I used printf "%s\n" because the ksh builtin echo treats \n in a special way.
Of course I put the $1 in "quotes" to have variable substitution but no further expansions. Note that a literal \ in " " is special but not if it stems from a variable substitution.
So sed sees s/\\\\n/ /g, and treats each \\ as one \
Last edited by MadeInGermany; 10-02-2019 at 05:32 AM..
This User Gave Thanks to MadeInGermany For This Post:
Hi
! /bin/sh
set logdir1 "logDir/local/logname"
#write the filename into a file
echo $logdir1 >> logname.txt
how do i exec the above echo command (1 Reply)
Hi there,
I have a wapper script which passes the argument from command prompt to inner script.. It works fine as long as the argument containing single word. But when value contains multiple word with space, not working as expected. I tried my best, couldn't find the reason. Gurus, pls.... (2 Replies)
Hi,
I am trying to write a script to cleanup files in a log directory ..
cd log
find Datk** -mtime +7 -exec rm -f {} \; 2> /dev/null
Have used the above to clean up files in log directory more then 7 days older.
The file can be something like ( auto-generate by some processes and... (2 Replies)
Hi,
I have a script output.sh which produces the following output (as an example):
"abc def" "ghi jkl"
This output should be handled from script input.sh as input and the quotes should be treated as variable delimiters but not as regular characters.
input.sh (processing positional... (2 Replies)
Hi i have written a shell script that takes only single ip address from the user and calculates its latency and reliability, can you please tell me that what should be done if i want that user should enter 100 or 1000 ip address (5 Replies)
Hi All,
I am new to this forum and also shell script :)
My task is I have to read CSV file get the data from the file and use the data to call c executable with data as argument.And the output from c executable should be stored to new CSV file
Please find below my code
testfunction() {... (14 Replies)
Hi,
I want to change a file file1.txt:
1234
3456
2345
6789
3456
2333
4444
As, file2.txt in Linux:
'1234','3456','2345','6789','3456','2333','4444'
Could someone please help me. (Single liner sed, awk will be welcome!) (7 Replies)
Hi Froum.
I have tried in vain to find a solution for this problem - I'm trying to replace any double quotes within a quoted string with a single quote, leaving everything else as is.
I have the following data:
Before:
... (32 Replies)
Hi all,
i am new to this forum, unix and shell scripting.
I would really appreciate if you all can help me here..
I have files coming in the below format
'filename20513'13May06:03:45
filename are characters..
like 'ABDDUT20513'13May06:03:45
i need it to be renamed as... (17 Replies)
Discussion started by: khman
17 Replies
LEARN ABOUT SUSE
lindex
lindex(n) Tcl Built-In Commands lindex(n)
__________________________________________________________________________________________________________________________________________________NAME
lindex - Retrieve an element from a list
SYNOPSIS
lindex list ?index...?
_________________________________________________________________DESCRIPTION
The lindex command accepts a parameter, list, which it treats as a Tcl list. It also accepts zero or more indices into the list. The
indices may be presented either consecutively on the command line, or grouped in a Tcl list and presented as a single argument.
If no indices are presented, the command takes the form:
lindex list
or
lindex list {}
In this case, the return value of lindex is simply the value of the list parameter.
When presented with a single index, the lindex command treats list as a Tcl list and returns the index'th element from it (0 refers to the
first element of the list). In extracting the element, lindex observes the same rules concerning braces and quotes and backslashes as the
Tcl command interpreter; however, variable substitution and command substitution do not occur. If index is negative or greater than or
equal to the number of elements in value, then an empty string is returned. The interpretation of each simple index value is the same as |
for the command string index, supporting simple index arithmetic and indices relative to the end of the list.
If additional index arguments are supplied, then each argument is used in turn to select an element from the previous indexing operation,
allowing the script to select elements from sublists. The command,
lindex $a 1 2 3
or
lindex $a {1 2 3}
is synonymous with
lindex [lindex [lindex $a 1] 2] 3
EXAMPLES
lindex {a b c}
-> a b c
lindex {a b c} {}
-> a b c
lindex {a b c} 0
-> a
lindex {a b c} 2
-> c
lindex {a b c} end
-> c
lindex {a b c} end-1
-> b
lindex {{a b c} {d e f} {g h i}} 2 1
-> h
lindex {{a b c} {d e f} {g h i}} {2 1}
-> h
lindex {{{a b} {c d}} {{e f} {g h}}} 1 1 0
-> g
lindex {{{a b} {c d}} {{e f} {g h}}} {1 1 0}
-> g
SEE ALSO
list(n), lappend(n), linsert(n), llength(n), lsearch(n), lset(n), lsort(n), lrange(n), lreplace(n), string(n) |
KEYWORDS
element, index, list
Tcl 8.4 lindex(n)