Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Inspecting leading char in string for slash Post 302949855 by neutronscott on Thursday 16th of July 2015 03:53:07 PM
Old 07-16-2015
SCO should have ksh available? You didn't say which shell you're using.

You cannot use a regex but a shell pattern such as [[ "$i" = /* ]]
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Shell script: Cut / (slash) character in string

I have a string "\/scratch\/databases\". I want to have a new string "\/scratch\/databases" by cutting last '\' character using shell script. I can't do this Please help me. Thanks in advance ThuongTranVN (4 Replies)
Discussion started by: ThuongTranVN
4 Replies

2. Programming

touching a file which contains slash char

i need to create a file which contains (/) character. Any help to do this (1 Reply)
Discussion started by: axes
1 Replies

3. UNIX for Dummies Questions & Answers

trim leading zero in certain column in a string

I would like to know how to trim leading zero only in certain column of of a string, example: hdhshdhdhd000012mmmm0002abc <===== before hdhshdhdhd 12mmmm 2abc <===== after Thanks for your help. (2 Replies)
Discussion started by: dngo
2 Replies

4. UNIX for Dummies Questions & Answers

Read a string with leading spaces and find the length of the string

HI In my script, i am reading the input from the user and want to find the length of the string. The input may contain leading spaces. Right now, when leading spaces are there, they are not counted. Kindly help me My script is like below. I am using the ksh. #!/usr/bin/ksh echo... (2 Replies)
Discussion started by: dayamatrix
2 Replies

5. Shell Programming and Scripting

Using sed to append backward slash before forward slash

Hi all, I need to know way of inserting backward slash before forward slash. My problem is that i need to supply directory path as an argument while invoking cshell script. This argument is further used in script (i.e. sed is used to insert this path in some file). So i need to place \ in front... (2 Replies)
Discussion started by: sarbjit
2 Replies

6. Shell Programming and Scripting

How to concatenate string containing a leading dash?

Is there a way to concatenate two strings, where the first string is "-n" and there is a space between the "-n" and the second string? Below are some examples of what I tried. #!/bin/sh var1=test #working without dashes: var2="n $var1" echo $var2 var2=n" "$var1 echo $var2 var2="n... (5 Replies)
Discussion started by: wolfv
5 Replies

7. Shell Programming and Scripting

Strip leading and numbers from a string.

Hello I have two vars loaded with $VAR1="ISOMETHING103" $VAR2="COTHERTHING04" I need to: 1) Strip the first char. Could be sed 's/^.//' 2) The number has it's rules. If it has "hundreds", it needs to be striped. If it is just two digits it shouldn't. So, for VAR1 output should be... (7 Replies)
Discussion started by: tristezo2k
7 Replies

8. Shell Programming and Scripting

Remove leading dot and slash on relative paths with find

When I specify a directory by name the leading ./ is not shown: $ find somedir/ somedir/a.bin somedir/target/out.binBut when I specify current dir it adds the ./ to the beginning of each result: $ find . | grep somedir ./somedir/a.bin ./somedir/target/out.binIs there any particular reason why... (2 Replies)
Discussion started by: Tribe
2 Replies

9. Shell Programming and Scripting

awk pad 1 column with leading zero if char > 12

Hello, I got a question. I have several csv files with lots of data in it and for the first column i have EAN codes. The problem that i am facing is that some of these codes have the leading 0 removed so they are 12 or less chars while a EAN code is (always?) 13 chars. For this i used a... (9 Replies)
Discussion started by: SDohmen
9 Replies

10. UNIX for Beginners Questions & Answers

Replace string until 3Rd occurance of forward slash(/)

I have a file abc.txt which has records like 456 /home/fgg/abdc.txt 3567 /home/fdss/vfgb.txt 23 /home/asd/dfght.txt I WANT TO REMOVE STRING UNTIL 3RD OCCURANCE OF FORWARD SLASH Output should be like abdc.txt vfgb.txt dfght.txt (5 Replies)
Discussion started by: himanshupant
5 Replies
strtoimax(3C)															     strtoimax(3C)

NAME
strtoimax(), strtoumax() - convert string to integer SYNOPSIS
DESCRIPTION
or converts the character string pointed to by str to or representation, respectively. The string is scanned up to the first character inconsistent with the base. Leading ``white-space'' characters (as defined by in ctype(3C)) are ignored. If no conversion can take place, zero is returned. If base is greater than or equal to 2 and less than or equal to 36, it is used as the base for conversion. After an optional leading sign, leading zeros are ignored, and or is ignored if base is 16. If base is zero, the string itself determines the base as follows: after an optional leading sign, a leading zero indicates octal conver- sion; a leading or indicates hexadecimal conversion. Otherwise, decimal conversion is used. If the value of ptr is not a pointer to the character terminating the scan is returned in the location pointed to by ptr. If no integer can be formed, the location pointed to by ptr is set to str, and zero is returned. RETURN VALUE
Upon successful completion, all functions return the converted value, if any. If the correct value would cause overflow: returns or (according to the sign of the value), and sets to returns and sets to For all other errors, zero is returned and is set to indicate the error. ERRORS
and fail and is set, if any of the following conditions are encountered: The value of base is not supported. The value to be returned would have caused overflow. AUTHOR
and were developed by HP. SEE ALSO
ctype(3C), strtod(3C), strtol(3C), scanf(3S), thread_safety(5). STANDARDS CONFORMANCE
strtoimax(3C)
All times are GMT -4. The time now is 03:02 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy