Programming :: SED Assistance: Add Character In The Middle Of A String?
Oct 20, 2010
I have a folder of MP3s, where some have <artist>- <song> and others have <artist> - <song>. I wanted to make all of them say <artist> - <song>
The command that works for me was
for i in *[a-Z]-*; do mv "$i" "`echo $i | sed 's/-/ -/g'`"; done
but if I -hadn't- used ls with my parameters to filter out the valid results, how would I have done this with sed? I got close with:
ls | sed -e 's/(.*)[a-Z]-(.*)/1 - 2/'
but with the above I lose the [a-Z] character that I used to match with (and I need to keep that).
View 4 Replies
ADVERTISEMENT
Mar 23, 2011
I have been reading through C source code to try to improve myself. In the coreutils source code, there are often function calls like so:
Code:
fprintf (stderr, _("Try `%s --help' for more information.
"), program_name);
Why is that string in the middle surrounded by parentheses and preceded by an underscore?
View 6 Replies
View Related
Oct 23, 2010
i am compiling the following program in linux. it's in c language. after the compilation with gcc when i run the executable file. it asks for input. but when i enter a name. i prints "Segmentation fault" and then terminate the program. can you please help me.
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
#include <unistd.h>
[code]....
View 1 Replies
View Related
Jan 19, 2011
how to replace last character string. For example
$>export T1=abcde
$>export T2=xyz
how to get result abcdxyz?
View 10 Replies
View Related
Aug 18, 2010
i have problem in java. how to convert string array to character. e.g string a[]={"ab","abc","abd","ag"}; what will be the character array ?
View 3 Replies
View Related
May 4, 2009
Inside a loop i'm populating a string variable. Because csh doesn't have very good support for arrays I thought of doing this. I want to add a new line character to the end of the concatenation each time the loop iterates. Then at the end print this variable out.
I tried " and some resources said it was just a "". Neither work. What am I doing wrong?
View 1 Replies
View Related
Jul 16, 2010
I have a large text file that's formatted sort of like this:
Code:
foo bar
blah
[code]...
View 2 Replies
View Related
Mar 30, 2010
I want to use SED to do the following: In a text file replace any occurrences of the three character string ZZZ with a quotation mark "and. replace all occurrences of a comma with a semi-colon. It is the S/ / / command which is stumping me on the first issue...inparticular how to get the replace string to be quote.
View 9 Replies
View Related
Oct 22, 2010
copy string a to string b and change string b with toupper() and count the chars
View 3 Replies
View Related
Dec 1, 2010
How can I search "$" in vim, which is not the end of line but the real char '$'.
View 1 Replies
View Related
May 18, 2010
Like the following c++ program, I define a pointer of char type in the class named "test". In the function init1(), str="hello1" , what is the existing period of "hello1". Whether the string "hello1" will be invalid if the function init1() exits ? then "str" point to the invalid field in memory. When will "hello1" and "hello2" be released by OS ?
Where is "hello1" stored in memory?
Code:
When will "hello everyone" be released?
View 1 Replies
View Related
May 18, 2011
Operating System: CentOS 5.4 I have a bash script that runs another php script to return a decrypted password. The return value is right but when I concatenate it with another string, I would not have the whole string. To better understand the problem, here is my script:
***********************************************************************************
#!/bin/bash
getProperty()
[code].....
View 1 Replies
View Related
Apr 11, 2011
I want to match some filename in some text, but the filenames I have no control of, so "[" can "]" can appear in the filenames.so do I always have to use sed to addslashes to these variables before I have to grep them? and what other characters have I missed other than "[", "]", "."?
View 4 Replies
View Related
Jul 18, 2011
We're migrating from Tomcat on Linux to Glassfish on Windows and I'm trying to make it easier to find the servlets that we don't currently have implicitly mapped in the Tomcat web.xml files for contexts. What I've done is copy all our contexts to a temp directory and written a script so that I can loop through each context, find the files that are not mapped inside a package then check if the java file is a servlet or not. From there I store each java file that matches, strip off the extension and then search in the context web.xml for a match then output to the screen.
The problem that I'm running into is that I know there are class files that should be returned and yet they are not being displayed. I'm not a Linux guy, so I'm just looking for a little help to see if I'm missing something obvious. I've attached the code for the script below.
Code:
# for all contexts
for context in `ls "/var/tomcat/temp/script/" | grep -v servletmap.sh`
do
echo $context
# for all java files without a package
[Code]...
View 6 Replies
View Related
May 3, 2011
I've been trying to understand pthread in C a little better. So I made a simple program that takes in a string from the command line and creates a thread to print the string. I've looked online and copied the basic concepts but there are something things I'm confused about. The programs works just fine, but I have questions. Here's what I have so far.
[Code]....
One thing I'd like to know is why the 3rd argument in the pthread_create function which is my SendMessage function needs to be typecasted to a void pointer and then send the address of the function. Also as for the 4th argument, I would see typecasting to void pointer in some of the pthread examples I saw online, but in my case I'm passing a char pointer, would this be correct? In which case would I ever want to pass a void pointer?
Do I need a pthread_exit(NULL) in my main and in the SendMessage function? If so, why? I added the sleep() function so that I could let the pthread_exit function in my SendMessage function execute first. I simply saw that the online examples on pthread had pthread_exit() in both locations.
View 6 Replies
View Related
Mar 27, 2010
1.What character instructd the shell to interpret a special character as an ordinary character?
2.What directory contains some of the utilities available on the system in the form of binary files?
3. What command is used to search the location of a utility?
4. What command is used to instruct the editor to write the file and quit the editor?
5. What key quits the more utility and displays the shell prompt?
6. What command starts a child shell as the super user, taking on root's identity and environment?
7. Which wildcard characters can be used for searching all the files in the system that start with "A"?
8. The user name or login name of the super user is????
[Code]....
View 10 Replies
View Related
Oct 16, 2010
I have a set of lines as ahown below:
Leon went to school
Leon came back from school..
Leon had dinner...
I have to replace the line containing "dinner" by a single string LUNCH...
View 2 Replies
View Related
Feb 25, 2011
I need to creates string suffixes out of a Reference string. for eg. suffixes of abcdefg will be
1)bcdefg
2)cdefg
3)defg
and so on...
create an array of pointers to point to the first few characters and then use that pointer to print the rest of the string.But when i print using the pointer i get GARBAGE values! shudn't std::cout<<ptr[w] print the string following the char it is pointing to? why do i get garbage values?
View 9 Replies
View Related
Apr 18, 2010
So if I'm given a location of a file like:
How can I just take the type of the file at the end? I know I can use strrchr() for a period to get the pointer to the period just before file type. Is there a build in string function that will just take the rest of the string from a certain point on forward in the string? I know it wouldn't be much work to make it myself, but I figured I would find out if it already existed before doing it.
View 9 Replies
View Related
Mar 13, 2010
Code:
The error is:
Code:
What I want to do is take input of ip4 as a string, convert it to an integer to add 1 to it, then reconvert it back to a string. Its not working.
My full code is:
Code:
View 1 Replies
View Related
Oct 12, 2009
I've been given a custom-made string class which handles string, wstring and bstr. It has a number of methods and assignment operators to convert to and from different types. The app I work on compiles happily in VS6 and VS2008, but when trying to compile in Redhat (version 4.1.1 in Redhat 5.0)
[code]....
View 4 Replies
View Related
Nov 11, 2010
I have the following two type of strings1: A/D2: A/C/DI am trying to write a subroutine to check whether all of the letters in string 1 appears in string 2. If yes, return true. If not, return false. In the above example, all the letters (A and D) in string 1 are also present in string 2, so I return true.
View 4 Replies
View Related
May 7, 2011
How to grep a string like "ab?c12345678" where 3rd character is unknown, while other characters are known.
View 2 Replies
View Related
Nov 18, 2010
I have this statement which greps .csv files. Code:my @files=grep {$_ =~ /.csv/}What about if I needed to get files with the word 'hosts' in the middle?
View 2 Replies
View Related
Mar 26, 2011
Do I have the convert the int to a string using stringstream then convert the string to a char? or is there a more direct way?Also is there a way to tell the length of a int?
View 5 Replies
View Related
Feb 2, 2015
Ctrl-c with middle mouse button (MMB) trigger in running bash script trigger.
The key combination Ctrl-C or "^C" with the keyboard triggered on a running bash script stands for "signal interrupt" (SIGINT) and terminates the process.
For my workflow in the test phase, how I could do that with the MMB-Buffer, followed by the modified script command:
Code: Select allscript runs
script runs
script runs
Signal interrupt and rerun with MMB trigger:
Code: Select all^C; ./script.sh
modified script runs
modified script runs
does not work and 2 hours meta-crawlers
View 1 Replies
View Related
Jun 27, 2010
I have a string like this "/home/test/filename.txt" and i want to delete all character after the last "/". how to do that using sed or awk.
View 5 Replies
View Related
Nov 3, 2010
I was reading Kernighan Ritchie book chapter 4 which deals with character pointers.I am not able to understand following different type of declarations
Code:
char aname[][15] = { "Illegal month", "Jan", "Feb", "Mar" };
char amessage[] = "now is the time";
[code]...
View 1 Replies
View Related
Feb 24, 2010
which is the simplest way to have first and last character cropped out from a string? Something simpler than
Code:
echo $STRING | cut -b 2- | rev | cut -b 2- | rev
View 6 Replies
View Related
Mar 30, 2010
I have the following file:
Code:
1 line
...
49 test test=AA:AA:AA:AA:AA=0
I need to substitute on the line number 49, all text until =. I have used the following, but with no actual result.
sed -re '49s/^.+=//' file
and
sed -e '49s/.*[=]//' file
View 5 Replies
View Related