Sponsored Content
Top Forums Shell Programming and Scripting read a string from its end to its start and stop when you find a specific character Post 302449825 by hakermania on Tuesday 31st of August 2010 05:04:02 PM
Old 08-31-2010
Question read a string from its end to its start and stop when you find a specific character

How can I do this? Actually I have a file which contains a path
e.g.
/home/john/Music/hello.mp3
and I want to take only the filename (hello.mp3) So, I need to read the file from its end to its start till the character "/"
Is this possible?
Thanks, I am sure you'll not disappoint me here!
Oh, yes, you are the best!Smilie
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

cut from a particular character to the end of the string

Hi All, I have a string like "9633C01302_2". I need to extract the number(02) after "13" and before "_" and the number coming after "13" and before "_" is not constant, it keeps on changing... Can some one plz help me wth the command.. i tried this echo "9633C01302_2" | cut -d'_' -f1 ..But... (2 Replies)
Discussion started by: grajesh_955
2 Replies

2. Shell Programming and Scripting

String as both start and end anchors in awk

Not sure if the title of this thread makes sense, but hopefully my explanation will. I'm using awk to print some stats from an apache accesslog. I would like to specify the regexp condition where only the two root pages of "index.html" and "/" are counted in my results. What I can't figure out... (3 Replies)
Discussion started by: picassolsus
3 Replies

3. UNIX for Dummies Questions & Answers

Extract a specific number from an XML file based on the start and end tags

Hello People, I have the following contents in an XML file ........... ........... .......... ........... <Details = "Sample Details"> <Name>Bob</Name> <Age>34</Age> <Address>CA</Address> <ContactNumber>1234</ContactNumber> </Details> ........... ............. .............. (4 Replies)
Discussion started by: sushant172
4 Replies

4. Shell Programming and Scripting

Appending string, variable to file at the start and string at end

Hi , I have below file with 13 columns. I need 2-13 columns seperated by comma and I want to append each row with a string "INSERT INTO xxx" in the begining as 1st column and then a variable "$node" and then $2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13 and at the end another string " ; COMMIT;" ... (4 Replies)
Discussion started by: Vaddadi
4 Replies

5. UNIX for Dummies Questions & Answers

Find Quarter Start and End Dates

Dear Members, Depending on the current date i should find out the start and end dates of the quarter. ex: Today date is 14-Nov-2011 then Quarter start date should be Oct 1 2011 and Quarter End date should be Dec 31 2011. How can i do this? Thanks Sandeep (1 Reply)
Discussion started by: sandeep_1105
1 Replies

6. Shell Programming and Scripting

how to specify start and stop of a search string

I am trying to extract a string from a line of text. Currently I am using grep -o 'startofstring(.........' The string is not always the same size. The string I'm trying to extract starts with 'test(' ends with ')'. ex "blah,blah,blah,test(stringoftext),blah blah" How do I... (4 Replies)
Discussion started by: jeepguy
4 Replies

7. Shell Programming and Scripting

Remove lines between the start string and end string including start and end string Python

Hi, I am trying to remove lines once a string is found till another string is found including the start string and end string. I want to basically grab all the lines starting with color (closing bracket). PS: The line after the closing bracket for color could be anything (currently 'more').... (1 Reply)
Discussion started by: Dabheeruz
1 Replies

8. Shell Programming and Scripting

Read command stop on either EOF or a specific line

I'm trying to stop reading a file until the end of the file is reached or a defined delimiter line is reached. Some how I need to test the fail state of the last 2 commands, not just the last command. echo -e "hello\ngoodbye\n####\ntesting" | while read line; ]; do echo "$line"; done hello... (4 Replies)
Discussion started by: Michael Stora
4 Replies

9. Shell Programming and Scripting

Find between lines start and end: awk with bash variables

I have a file as follows: 0 1056 85540 414329 774485 1208487 1657519 2102753 2561259 3037737 3458144 3993019 4417959 4809964 5261890 5798778 6254146 I want to find all lines between a specified start and end tag. (6 Replies)
Discussion started by: jamie_123
6 Replies

10. Shell Programming and Scripting

Search a String between start and end of a block in a file

Hi, I have a scenario where I want to display the output based on the pattern search between the start and end of a block in a file, we can have multiple start and end blocks in a file. Example give below, we need to search between the start block abc and end block def in a file, after that... (5 Replies)
Discussion started by: G.K.K
5 Replies
pods::SDL::Mixer::Music(3pm)				User Contributed Perl Documentation			      pods::SDL::Mixer::Music(3pm)

NAME
SDL::Mixer::Music - functions for music CATEGORY
Mixer METHODS
load_MUS my $music = SDL::Mixer::Music::load_MUS( $file ); "load_MUS" loads a music file into a "SDL::Mixer::MixMusic" structure. This can be passed to play_music. load_MUS_RW my $music = SDL::Mixer::Music::load_MUS_RW( $rwops ); "load_MUS_RW" does the same like "load_MUS" except that it accepts an SDL::RWOps-object rather than a filename. Example for loading music from a variable: use SDL; use SDL::Mixer; use SDL::Mixer::Music; use SDL::RWOps; [...] my $rwops = SDL::RWOps->new_const_mem( $scalar_holding_music ); my $music = SDL::Mixer::Music::load_MUS( $rwops ); Note: You need at least libSDL_mixer 1.2.7 for this feature. hook_music SDL::Mixer::Music::hook_music( $callback, $position ); This sets up a custom music player function, so you can pass your own audio stream data into the SDL::Mixer. The function will be called with "position" passed into the first parameter when the "callback" is called. The audio stream buffer has to be filled with length bytes of music (2nd parameter). The music player will then be called automatically when the mixer needs it. Music playing will start as soon as this is called. All the music playing and stopping functions have no effect on music after this. Pause and resume will work. Using a custom music player and the internal music player is not possible, the custom music player takes priority. To stop the custom music player call "hook_music()" without arguments. Note: NEVER call "SDL::Mixer" functions, nor SDL::Audio::lock, from a callback function. Note: At program termination also call "SDL::Mixer::Music::hook_music()" to stop this callback. Example: sub callback { my $position = shift; # position (first time its 0, on each call $length is added) my $length = shift; # length of bytes we have to put in stream my @stream = ''; printf("position=%8d, stream length=%6d ", $position, $length); for(my $i = 0; $i < $length; $i++) { push(@stream, (($i + $position) & 0xFF)); } return @stream; } SDL::Mixer::Music::hook_music( 'main::callback', 0 ); hook_music_finished SDL::Mixer::Music::hook_music_finished( 'main::callback' ); This callback is called when music called by e.g. SDL::Mixer::Music::play_music or SDL::Mixer::Music::fade_in_music stops naturally. This happens when the music is over or is fading out. Note: If you play music via SDL::Mixer::Music::hook_music, this callback will never be called. Example: my $music_is_playing = 0; my @music = qw(first.mp3 next.mp3 other.mp3 last.mp3); sub callback { $music_is_playing = 0; } SDL::Mixer::Music::hook_music_finished( 'main::callback' ); foreach my $this_song ( @music ) { SDL::Mixer::Music::play_music( $this_song, 0 ); $music_is_playing = 1; SDL::delay( 100 ) while( $music_is_playing ); } SDL::Mixer::Music::hook_music_finished(); # cleanup get_music_hook_data my $position = SDL::Mixer::Music::get_music_hook_data(); Returns the "position" (first) parameter that will be passed to SDL::Mixer::Music::hook_music's callback. play_music my $play_music = SDL::Mixer::Music::play_music( $mix_music, $loops ); "play_music" plays a given "SDL::Mixer::MixMusic". Passing -1 to $loops will loop the music infinitely. Example: my $music = SDL::Mixer::Music::load_MUS( 'music.mp3' ); unless(SDL::Mixer::Music::play_music($sample_music, -1)) { print("Something went wrong! "); } fade_in_music my $music = SDL::Mixer::Music::fade_in_music( $mix_music, $loops, $ms ); Same as SDL::Mixer::Music::play_music but you can specify the fade-in time by $ms. fade_out_music my $fading_music = SDL::Mixer::Music::fade_out_music( $ms ); "fade_out_music" fades out the music with a duration specified in "ms" in milliseconds. Returns the the number of channels that will be faded out. fading_music my $fading_music = SDL::Mixer::Music::fading_music(); Returns one of the following: o MIX_NO_FADING o MIX_FADING_OUT o MIX_FADING_IN volume_music my $volume_before = SDL::Mixer::Music::volume_music( $new_volume ); "volume_music" set the volume in $new_volume and returns the volume that was set before. Passing "-1" as argument causes only to return the current volume. Volume is between 0 (silence) and "MIX_MAX_VOLUME = 128". Example: # set the music volume to 1/2 maximum, and then check it printf( "volume was : %d ", SDL::Mixer::Music::volume_music( MIX_MAX_VOLUME / 2 ) ); printf( "volume is now : %d ", SDL::Mixer::Music::volume_music( -1 ) ); halt_music SDL::Mixer::Music::halt_music(); Halts the music. pause_music SDL::Mixer::Music::pause_music(); Pauses the music. resume_music SDL::Mixer::Music::resume_music(); Resumes the music. rewind_music SDL::Mixer::Music::rewind_music(); Rewinds the music. set_music_position SDL::Mixer::Music::set_music_position( $position ); Set the position of the currently playing music. The position takes different meanings for different music sources. It only works on the music sources listed below. MOD The double is cast to Uint16 and used for a pattern number in the module. Passing zero is similar to rewinding the song. OGG Jumps to position seconds from the beginning of the song. MP3 Jumps to position seconds from the current position in the stream. So you may want to call SDL::Mixer::Music::rewind_music before this. Does not go in reverse... negative values do nothing. Returns: 0 on success, or "-1" if the codec doesn't support this function. paused_music my $paused = SDL::Mixer::Music::paused_music(); Returns 1 if the music is paused, otherwise 0. playing_music my $playing_music = SDL::Mixer::Music::playing_music(); Returns 1 if the music is playing sound, otherwise 0. It doesn't check if the music is paused. AUTHORS
See "AUTHORS" in SDL. perl v5.14.2 2012-05-28 pods::SDL::Mixer::Music(3pm)
All times are GMT -4. The time now is 04:22 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy