grepping a part of filenames


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting grepping a part of filenames
# 8  
Old 10-18-2006
Quote:
Originally Posted by vino
Interesting. The man pages for ksh dont mention anything of that construct. But yes, the bash man page does.
From the ksh man page:
Code:
${parameter:offset:length}
   ${parameter:offset}
          Expands to the portion of the value of parameter starting at
          the character (counting from 0) determined by expanding offset
          as an arithmetic expression and consisting of the number of
          characters determined by the arithmetic expression defined by
          length. In the second form, the remainder of the value is used.
          If parameter is * or @, or is an array name indexed by * or @,
          then offset and length refer to the array index and number of
          elements respectively.

# 9  
Old 10-18-2006
Quote:
Originally Posted by shereenmotor
From the ksh man page:
Code:
${parameter:offset:length}
   ${parameter:offset}
          Expands to the portion of the value of parameter starting at
          the character (counting from 0) determined by expanding offset
          as an arithmetic expression and consisting of the number of
          characters determined by the arithmetic expression defined by
          length. In the second form, the remainder of the value is used.
          If parameter is * or @, or is an array name indexed by * or @,
          then offset and length refer to the array index and number of
          elements respectively.


What version of ksh are you using? It's definitely not in 88, but I see it in pdksh, I don't have ksh93 handy to check.
# 10  
Old 10-18-2006
Quote:
Originally Posted by reborg
What version of ksh are you using? It's definitely not in 88, but I see it in pdksh, I don't have ksh93 handy to check.
I'm at ksh93.
# 11  
Old 10-18-2006
Built-in substring capabilities like that are not available in ksh88 -- only ksh93.
# 12  
Old 10-18-2006
Since this thread isn't about C programming, have moved it to the Scripting Q&A.

Cheers.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to make a loop to read the input from a file part by part?

Hi All, We've a VDI infrastructure in AWS (AWS workspaces) and we're planning to automate the process of provisioning workspaces. Instead of going to GUI console, and launching workspaces by selecting individual users is little time consuming. Thus, I want to create them in bunches from AWS CLI... (6 Replies)
Discussion started by: arun_adm
6 Replies

2. Shell Programming and Scripting

Renaming Filenames by replacing a part

Hi, I have little experience on Shell scripts, I searched the forum but couldn't make out what I want. I want to rename a set of files to a new file name a_b_20100101 c_d_20100101 ....................... ...................... I want to rename the files to a_b_20140101... (5 Replies)
Discussion started by: JaisonJ
5 Replies

3. Shell Programming and Scripting

[Solved] Printing a part of the last line of the specific part of a file

Hi, I have 80 large files, from which I want to get a specific value to run a Bash script. Firstly, I want to get the part of a file which contains this: Name =A xxxxxx yyyyyy zzzzzz aaaaaa bbbbbb Value = 57 This is necessary because in a file there are written more lines which... (6 Replies)
Discussion started by: wenclu
6 Replies

4. Shell Programming and Scripting

Change part of filenames in a bulk way

Hallo! I have generated lots of data file which all having this format: sp*t1overt2*.txt Now I want to change them in this way: sp*t2overt1*.txt The rest of the file names stay unchanged. I know this is kind of routine action in sed or awk, but dont know how! I tried this command: ... (6 Replies)
Discussion started by: forgi
6 Replies

5. Shell Programming and Scripting

Returning only part of a line when grepping

I want to grep out a part of a snort rule based on the SID given, but all i want as the output is the part in the quotes after the msg: An example line looks something like this: alert tcp any any -> 127.0.0.1 any (msg:"Example Message"; classtype:Example; sid:123456;) I would want it to... (7 Replies)
Discussion started by: riott
7 Replies

6. Shell Programming and Scripting

BASH: Grepping/sedding/etc out part of a file... (from one word to 'blank' line)

I have a file that lists data about a system. It has a part that can look like: the errors I'm looking for with other errors: Alerts Password Incorrect Login Error Another Error Another Error 2 Other Info or, just the errors I need to parse for: Alerts Password Incorrect ... (9 Replies)
Discussion started by: elinenbe
9 Replies

7. Shell Programming and Scripting

comparing part of header with part of detailed records.

Hi there, I am lil confused with the following issue. I have a File, which has the following header: IMSHRATE_043008_101016 a sample detailed record is :9820101 A982005000CAVG030108000000000000010169000MAR 2008 9820102 MAR 2008 D030108 ... (1 Reply)
Discussion started by: cmaroju
1 Replies

8. Shell Programming and Scripting

grepping around

Using shell scripts, I use grep to find the word “error” in a log file: grep error this.log. How can I print or get the line 3 lines below the line that word “error” is located? Thanks in advance for your response. (9 Replies)
Discussion started by: cbeauty
9 Replies

9. Shell Programming and Scripting

Grepping for filenames containing value in specific segment within file

I am trying to grep for filenames containing a specific value within a particular segment. The lines containing the segment I'm looking through reads like "HL^1^^1^1", "10^9^9^0", and "HL^11^4^8^1". I would like to find the data that contains only the number nine after the third caret where the... (4 Replies)
Discussion started by: HLee1981
4 Replies

10. UNIX for Dummies Questions & Answers

grepping

Is there a way to grep for something and then print out 10 lines after it. for example if I want to grep for a word, then output the following 10 or whatever number of lines after the word. (5 Replies)
Discussion started by: eloquent99
5 Replies
Login or Register to Ask a Question