Sponsored Content
Full Discussion: Cut the path into two parts
Top Forums Shell Programming and Scripting Cut the path into two parts Post 302831011 by zaxxon on Wednesday 10th of July 2013 04:08:22 AM
Old 07-10-2013
Code:
$ echo ${file%/*}
/usr

 

8 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

cut file details from the path given

Hi, Filenames come as /DataStage/temp/ERT/infile/RU.ER.09.0106.txt in a file. I want to cut first 2 chars of the filename like RU, then next 2 like ER and next like 09 I tried using var=/DataStage/temp/ERT/infile/RU.ER.09.0106.txt echo $var|cut -f 1 -d .(dot) this gives... (2 Replies)
Discussion started by: harshada
2 Replies

2. UNIX for Dummies Questions & Answers

How to cut a string in two parts and show the other part

hi everybody.. I have a string like : abcd:efgh xxyy:yyxx ssddf:kjlioi ghtyu:jkksk nhjkk:heuiiue please tell me how i can display only the characters after ":" in the output the output should be : efgh yyxx kjlioi jkksk heuiiue please give quick reply.. its urgent..!! (6 Replies)
Discussion started by: adityamitra
6 Replies

3. UNIX for Dummies Questions & Answers

Extracting parts from an absolute path

Hi, How can I extract parts from an absolute path? For example : The absolute path is /dir1/dir2/dir3/dir4/dir5.I need the relative path starting with directory given as parameter : for instance if the parameter is dir3 then the result should be dir3/dir4/dir5 I need generic solution... (9 Replies)
Discussion started by: mortanon
9 Replies

4. Shell Programming and Scripting

Cut Command error cut: Bad range

Hi Can anyone what I am doing wrong while using cut command. for f in *.log do logfilename=$f Log "Log file Name: $logfilename" logfile1=`basename $logfilename .log` flength=${#logfile1} Log "file length $flength" from_length=$(($flength - 15)) Log "from... (2 Replies)
Discussion started by: dgmm
2 Replies

5. Shell Programming and Scripting

Incrementing parts of ten digits number by parts

I have number in file which contains date and serial number: 2013101000. The last two digits are serial number (00). So maximum of serial number is 100. After reaching 100 it becomes 00 with incrementing 10 which is day with max 31. after reaching 31 it becomes 00 and increments 10... (31 Replies)
Discussion started by: Natalie
31 Replies

6. Shell Programming and Scripting

Parsing a log file to cut off some parts

Dear all, I would like to use SQL's log file to extract information from it. This file can include four different types of instruction with the number of lines involved for each of them: -> (1) "INSERT" instruction with the number of lines inserted -> (2) "UPDATE" instruction with the... (4 Replies)
Discussion started by: dae
4 Replies

7. UNIX for Advanced & Expert Users

Command to see the logical volume path, device mapper path and its corresponding dm device path

Currently I am using this laborious command lvdisplay | awk '/LV Path/ {p=$3} /LV Name/ {n=$3} /VG Name/ {v=$3} /Block device/ {d=$3; sub(".*:", "/dev/dm-", d); printf "%s\t%s\t%s\n", p, "/dev/mapper/"v"-"n, d}' Would like to know if there is any shorter method to get this mapping of... (2 Replies)
Discussion started by: royalibrahim
2 Replies

8. Shell Programming and Scripting

Using :<<cut / cut to comment out block of bash script

I am using : << cut / cut to comment out block of code. Works fine on few lines of script, then it gives me this cryptic error when I try to comment out about 80 lines. The "warning " is at last line of script. done < results 169 echo "END read all positioning parameters" 170... (8 Replies)
Discussion started by: annacreek
8 Replies
ECHO(3) 								 1								   ECHO(3)

echo - Output one or more strings

SYNOPSIS
void echo (string $arg1, [string $...]) DESCRIPTION
Outputs all parameters. echo is not actually a function (it is a language construct), so you are not required to use parentheses with it. echo (unlike some other language constructs) does not behave like a function, so it cannot always be used in the context of a function. Additionally, if you want to pass more than one parameter to echo, the parameters must not be enclosed within parentheses. echo also has a shortcut syntax, where you can immediately follow the opening tag with an equals sign. Prior to PHP 5.4.0, this short syn- tax only works with the short_open_tag configuration setting enabled. I have <?=$foo?> foo. PARAMETERS
o $arg1 - The parameter to output. o $... - RETURN VALUES
No value is returned. EXAMPLES
Example #1 echo examples <?php echo "Hello World"; echo "This spans multiple lines. The newlines will be output as well"; echo "This spans multiple lines. The newlines will be output as well."; echo "Escaping characters is done "Like this"."; // You can use variables inside of an echo statement $foo = "foobar"; $bar = "barbaz"; echo "foo is $foo"; // foo is foobar // You can also use arrays $baz = array("value" => "foo"); echo "this is {$baz['value']} !"; // this is foo ! // Using single quotes will print the variable name, not the value echo 'foo is $foo'; // foo is $foo // If you are not using any other characters, you can just echo variables echo $foo; // foobar echo $foo,$bar; // foobarbarbaz // Some people prefer passing multiple parameters to echo over concatenation. echo 'This ', 'string ', 'was ', 'made ', 'with multiple parameters.', chr(10); echo 'This ' . 'string ' . 'was ' . 'made ' . 'with concatenation.' . " "; echo <<<END This uses the "here document" syntax to output multiple lines with $variable interpolation. Note that the here document terminator must appear on a line with just a semicolon. no extra whitespace! END; // Because echo does not behave like a function, the following code is invalid. ($some_var) ? echo 'true' : echo 'false'; // However, the following examples will work: ($some_var) ? print 'true' : print 'false'; // print is also a construct, but // it behaves like a function, so // it may be used in this context. echo $some_var ? 'true': 'false'; // changing the statement around ?> NOTES
Note Because this is a language construct and not a function, it cannot be called using variable functions. SEE ALSO
print(3), printf(3), flush(3), Heredoc syntax. PHP Documentation Group ECHO(3)
All times are GMT -4. The time now is 10:05 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy