Sponsored Content
Full Discussion: Cut the path into two parts
Top Forums Shell Programming and Scripting Cut the path into two parts Post 302831003 by munna_dude on Wednesday 10th of July 2013 04:03:34 AM
Old 07-10-2013
Cut the path into two parts

Hi,

Code:
file=/usr/lib

I need to cut and put it into two variable like

Code:
string1=/usr
string2=lib

I made it for string2
Code:
string2=${file#/*/}

How to get String1 in the same way which I have get string2.

Moderator's Comments:
Mod Comment Use even more code tags Smilie

Last edited by zaxxon; 07-10-2013 at 05:06 AM.. Reason: code tags
 

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
bcopy(3)						     Library Functions Manual							  bcopy(3)

NAME
bcopy, bcmp, bzero - Perform memory operations LIBRARY
Standard C Library (libc) SYNOPSIS
#include <strings.h> void bcopy( const void *source, void *destination, size_t length); int bcmp( const void *string1, const void *string2, size_t length); void bzero( void *string, size_t length); The following function definitions do not conform to current standards and are supported only for backward compatibility: #include <string.h> void bcopy( const char *source, char *destination, int length); int bcmp( const char *string1, const char *string2, int length); void bzero( char *string, int length); STANDARDS
Interfaces documented on this reference page conform to industry standards as follows: bcopy(), bcmp(), bzero(): XSH5.0 Refer to the standards(5) reference page for more information about industry standards and associated tags. PARAMETERS
Points to the original string for the bcopy() function. Points to the destination string for the bcopy() function. Specifies the byte string to be compared to the string2 parameter by the bcmp() function. Specifies the byte string to be compared to the string1 parameter by the bcmp() function. Specifies the length (in bytes) of the string. DESCRIPTION
The bcopy(), bcmp(), and bzero() functions operate on variable length strings of bytes. Unlike the string functions, they do not check for null bytes. The bcopy() function copies the value of the length parameter in bytes from the string in the source parameter to the string in the desti- nation parameter. The bcmp() function compares the byte string in the string1 parameter against the byte string of the string2 parameter, returning a 0 (zero) value if the two strings are identical and a nonzero value otherwise. The bzero() function nulls the string in the string parameter, for the value of the length parameter in bytes. NOTES
[Tru64 UNIX] The bcopy() function is similar to the memcpy() function except that the first two parameters are reversed. RELATED INFORMATION
Functions: memccpy(3), memcpy(3), string(3), swab(3) Standards: standards(5) delim off bcopy(3)
All times are GMT -4. The time now is 02:49 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy