Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Splitting a variable at a specific characher Post 302560968 by Andrewx991 on Sunday 2nd of October 2011 02:58:20 PM
Old 10-02-2011
Splitting a variable at a specific characher

Hey, I'm somewhat new to writing scripts and I keep coming across a problem when I try to split a filename that contains a dash '-'.

For example:

SomeFoo - FooBar.foo

I want to split to SomeFoo and FooBar.foo

I tried using basename and cut but didn't have any luck.

Any suggestions/help?
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

want to specific line which i will give through variable

Hi, I have a file on unix which contains -------------------------------------- 1 # Do not remove the following line, or various programs 2 # that require network functionality will fail. 3 127.0.0.1 romhelp3 localhost.localdomain localhost 4 ... (2 Replies)
Discussion started by: srikanthus2002
2 Replies

2. Shell Programming and Scripting

Splitting av file in 2 at specific place based on textpattern

I have a file that I want to split in 2 (with Bourne shell sh) preferably. The file consists of groups of lines separated by newline. The file can vary in length, so I need to check number of groups of text. Here's an example ====EXAMPLE START==== #fruit banana #color yellow #surface smooth... (0 Replies)
Discussion started by: borgeh
0 Replies

3. Shell Programming and Scripting

How to read a specific column into variable

Hi, I want to read the 3rd column of the v_string into a script variable v_3rd, can anyone help howto? v_string="This is for testing only" Thanks! Victor Cheung (2 Replies)
Discussion started by: victorcheung
2 Replies

4. Shell Programming and Scripting

Splitting a variable based on newline char

Heeloo all, A weird problem perhaps. May god save others from this problem. I want to print each line from a variable.. the example below should make it clear. smvar="Hello World1 Hello world 2 forgot there I guess" for eachline in $smvar echo $eachline end Whats for... (3 Replies)
Discussion started by: pavanlimo
3 Replies

5. UNIX for Dummies Questions & Answers

Splitting files into a specific directory

Hello, I am trying to do the following; bzcat data.in.bz2 | split -l 1000000 -d this work great, except that once the files have been split, they are not in the directory I want them to be in. So I then have to move them, at times this can get hairy. Is there anyway to specify where the... (4 Replies)
Discussion started by: amcrisan
4 Replies

6. Shell Programming and Scripting

How to edit specific variable in file?

HI guys i have a question. Question 1: how do i modify a particular string? e.g echo "Please enter Book Title: " read a echo "Please enter Author: " read b if ] then echo " Record found!" which will then pop out a menu with the follow output 1. Update Name 2.... (1 Reply)
Discussion started by: ichar
1 Replies

7. Shell Programming and Scripting

perl, splitting out specific parts of the string

Hi there, I have an output from a command like this # ypcat -k netgroup.byuser| grep steven steven.* users_main,users_sysadmin,users_global,users_backup_team and wanted to pull the 'users' netgroups returned into a perl array, that will look like this users_main... (2 Replies)
Discussion started by: rethink
2 Replies

8. Shell Programming and Scripting

Using AWK to get a specific line using a variable

Hi I have a text like this example.input 1 red 2 blue 3 green If I set this c=2 Then try awk 'NR==$c { print $2 }' example.input I do get nothing If I try awk 'NR==2 { print $2 }' example.input i get blue (8 Replies)
Discussion started by: Jotne
8 Replies

9. Shell Programming and Scripting

Non trivial file splitting, saving with variable filename

Hello, Although I have found similar questions, I could not find advice that could help with our problem. The issue: We have a few thousands text files (books). Each book has many chapters. Each chapter is identified by a cite-key. We need to split each of those book files by... (4 Replies)
Discussion started by: samask
4 Replies

10. Shell Programming and Scripting

Print specific line using a variable

Hi Everyone, Is there a way I can print specific lines using sed -n '3,3p' file.dat or awk 'FNR==3' file.dat when using variable? For example, I have this script (get_line.ksh) that accepts line parameter that a user wanted to print in the file.dat. file.dat one two three four ... (1 Reply)
Discussion started by: zzavilz
1 Replies
MPB(1)							    MIT Photonic-Bands Package							    MPB(1)

NAME
mpb-split - compute eigenmodes with MPB using multiple processes SYNOPSIS
mpb-split NUM-SPLIT [DEFINITION]... [CTLFILE]... DESCRIPTION
mpb-split is a parallelizing front-end to MIT Photonic Bands (MPB). For a computation with several k points, it splits the list of k points over multiple processes. Of course, this will only benefit you on a system where different processes will run on different proces- sors, such as an SMP or a cluster with automatic process migration (e.g. MOSIX). mpb-split is actually a trivial shell script, though, so you can easily modify it if you need to use a special command to launch processes on other processors/machines. MIT Photonic Bands (MPB) is a free program to compute the band structures (dispersion relations) and electromagnetic modes of periodic dielectric structures, and is applicable both to photonic crystals (photonic band-gap materials) and a wide range of other optical prob- lems. More information on MPB, including a detailed manual, can be found online at the MPB home page: http://ab-initio.mit.edu/mpb/ A typical invocation of mpb-split looks like: mpb-split num-split foo.ctl >& foo.out This causes mpb-split to process the control file foo.ctl, divide the k points into num-split equal chunks, run each list in a separate process with MPB, and redirect the output (in order) to foo.out. (One typically redirects output to a file, as the output is verbose and contains a number of comma-delimited datasets that one can extract by grepping.) Overall, the behavior and arguments are the same as for mpb except that the first argument must be the integer num-split. What mpb-split technically does is to set the MPB variable k-split-num to num-split and k-split-index to the index (starting with 0) of the chunk for each process. If you want, you can use these variables to divide the problem in some other way and then reset them to 1 and 0, respectively. BUGS
Send bug reports to S. G. Johnson, stevenj@alum.mit.edu. AUTHORS
Written by Steven G. Johnson. Copyright (c) 1999, 2000, 2001, 2002 by the Massachusetts Institute of Technology. SEE ALSO
mpb(1), mpb-data(1) MPB
March 13, 2002 MPB(1)
All times are GMT -4. The time now is 10:53 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy