Did you try the man page for ksh? (man ksh) The man page has the info that you are looking for. If you have additional questions, after reading the specific areas in the man page, one of us can help.
The specific section you're interested in is "parameter expansion". You should find it documented in the man page of any shell that supports those idioms.
what does one # stand for?
what does two ## stand for?
what does % mean?
what does two signs %% mean?
what 1* means here?
what *1 means here?
I searched google but I got hard explanation and hard english.
I need someone to explain each command to me in easy words!
thanks.
${X} is a variable in its full syntax
Quote:
what does one # stand for?
Mask a regular expression, taking the less greedy portion, starting from left to right.
e.i.
Match as less as possible, zero or more characters, followed by a literal '1'
In your case if x="a1 b1 c2 d2" it matches 'a','1' and stops, returning the remainder as the result. "b1 c2 d2"
Quote:
what does two ## stand for?
Mask a regular expression taking the most greedy portion starting from left to right e.i
${x##*1} -> match as much as it can. Returns remainder.
if x="a1 b1 c2 d2" then it eats 'a','1',' ','b','1' and stops.
Quote:
what does % mean?
Start from right to left matching as less as possible.
Quote:
what does two signs %% mean?
Start from right to left matching as much as possible
Quote:
what 1* means here?
Match a literal '1' followed by zero or more characters. (translates to nothing or everything else after a '1' included)
Quote:
what *1 means here?
Match zero or more characters followed by a literal '1'. (Translates to everything before a literal '1' or nothing plus '1')
Hello All,
Could you please do help me here as I would like to perform parameter expansion in shell over a parameter expansion.
Let's say I have following variable.
path="/var/talend/nat/cdc"
Now to get only nat I could do following.
path1="${path%/*}"
path1="${path1##*/}"
Here... (8 Replies)
Hello.
I cannot write a command without using eval.
Any help is welcome
Note 1 : What does the function SOMETHING has no importance.
Note 2 : What does the command find has no importance.
It is an expansion variable problem : where to put or or or anythings else
What works (FILTRE_1... (8 Replies)
I want to split one file input.tab into two separate ones, odd lines to input_reads1.txt, even lines to input_reads2.txt for a serial of files with similar name pattern. Also I want to "match" input/output file names to keep consistency of file name:
CSEL_02.0_input.tab
CSEL_03.4_input.tab... (2 Replies)
This is what I have in my directory.
$ ls
test1.txt test2.txt test3.txt test4.txt test5.txt test_script.sh
This is what my shellscript looks like.
#!/bin/bash
for filename in /shell_expansion/*.txt; do
for ((i=0; i<=3; i++)); do
echo "$filename"
... (5 Replies)
Hi,
I'm trying to figure out whether some files exist. Locations of those file are stored in a plain text file called temp.txt in this way:
All environment variables ($LIB_HOME and $ORACLE_HOME) have been set using export command.
Then I do:
while read line; do ] && echo "OK ==> $line" ||... (6 Replies)
I have a bunch of files which I need to transfer to another location... and some of these I need to skip.
For e.g. let us say the files are:
cust_abc.dat
cust_xyz.dat
cust_def.dat
and I only want to move the first two.
I want to do something like:
cp cust_.dat <target>
... (1 Reply)
Hi ,
could anyone help me out with this problem.
sample.txt has this content :
u001- this is used for project1 ||
u002- this is used for p2|| not to be printed
u003- this is used
for project3 ||
u004- this is
used for p4 ||
u005- this is used for project5 ||
u006- this is used for p6... (9 Replies)
Hi,
I have a script that at one point prints to a file as follows:
printf -- $2 > ~/.mydir/$1
The idea is to print to a hidden directory .mydir in my home directory. I've already sanitized the inputs and $1 is in the format path1/path2/filename and $2 is some user input.
When I run this... (2 Replies)