General :: Selectively Remove Blank Spaces From String?
Oct 7, 2009
need all spaces between two letters or a letter and a number exchanged for an underscore, but all spaces between a letter and other characters need to remain. One example for clarity:
Input:
force -- lamin 90 [label]
active A -- generation [label]
needed Output:
force -- lamin_90 [label]
active_A -- generation [label]
I tried solving this with sed but obviously s/ /_/g does not work, nor does any s/[a-zA-z0-9] [a-zA-z0-9]/[a-zA-z0-9]_[a-zA-z0-9]/g , because you just can't do this...
View 2 Replies
ADVERTISEMENT
Feb 2, 2010
I need to seach a string containing
the substring of 'New Request object:'
and
the substring of '/0x2ab46b1f90' in vi editor,
how do I accomplish that?
View 7 Replies
View Related
May 7, 2010
I did the following script:
Code:
DIR=`pwd`;for i in `find . -name GESTION -type d`;do cd $i/..;setfacl -R -m g:directores:rwx,
GESTION;echo $DIR'/'$i;cd $DIR;done
This code do the following actions:
1. Starting inside a folder, it's searching for any folder called "GESTION"
2. Every time a folder called "GESTION" is found, then the script move to its parent folder, and then it applies ACL permissions to the folder GESTION by using the command setfacl.
The problem is that the script doesn't works when there was found a folder with a blank space in its name. I mean:
/dir1/dir2/dir3/GESTION --> this works fine
/dir1/dir2/dir 3/GESTION --> this doesn't works
/dir1/dir2/dir3/2. GESTION --> this doesn't works
View 4 Replies
View Related
Sep 14, 2010
I am reading the output of /proc/acpi/thermal_zone/ATF0/temperature in a program to read my CPU temp. I am using cat like the following:
Code:
#cat /proc/acpi/thermal_zone/ATF0/temperature
temperature: 49 C
I basically want to get rid of the spaces in between temperature and the actual temperature. Is there a command I can pipe the cat output to, to remove the spaces. I have seen suggestions for sed, or tr, but for some reason I cannot get them to work properly.
View 14 Replies
View Related
Nov 22, 2010
I'm hoping that someone can help me, I need to remove spaces (not replace with underscores) from several thousand files on a system with cygwin.
Can I do this from the shell using rename or mv somehow?
View 4 Replies
View Related
Oct 8, 2010
I have been trying to code a program in C++ that must check for the correct syntax in order to operate. It must find ", " within the string, but I don't know why the compiler won't recognizes spaces.
Code:
#include <iostream>
#include <stdio.h>
#include <string>
[Code]....
So the user must input "<name>, <interest>" with the ", " (comma and space) but even if you respect the syntax the compiler will skip to the else condition. I don't know why, but if I put any other condition like ",s" it will work, but not with spaces.
View 7 Replies
View Related
Nov 27, 2010
I have a file of the type:
a = b
where a is any string and b is an integer The 'a' string doesn't have any spaces in it.
Everything was running fine till I was searching for 'a' and finding value 'b' by expression
Code:
string="$a"
egrep -i -m1 "^[[:space:]]$string[[:space:]]*=" | awk -F'=' 'gsub(/^[[:space:]]+/,"",$2)gsub(/[[:space:]]+$/,"",$2){print $2}'
I recently ran into a situation where in the string 'a' had symbols like $, & in it. Though I haven't checked it for & but $ is definitely breaking my code
Any way to egrep for string with $ ??
One way I though was to replace every occurence of $ with $ in my search expression but that would involve an extra processing each time
View 10 Replies
View Related
Jan 26, 2010
Is it possible, in Linux, to rename a file from something without spaces to something containing spaces? I know I can create directories and files with spaces by doing:
mkdir "new dir" and:
touch "new file.txt"
I want to rename files from:
imgp0882.jpg to something like:
20091231 1243 some topic.jpg
And how would it look in a shell script that uses parameters like:
for i in *.jpg do
rename "$i" "$somepath/$mydate $mytime $mytopic$extension"
?
I'm new to Linux (using PCLinuxOS 2009.2), coming from Windows, and I've written myself a little shell script to download files from my camera and then automatically rename them according to a date-and-topic pattern. As you can guess by now, I'm stuck on the bit about renaming. If you want to see my script, here's a copy. I'm not using jhead for this renaming because that only works with JPEG files but I want a single solution for any media format including videos.
View 2 Replies
View Related
Aug 25, 2010
I have two sets of data. 1,2,3,4 and 6,7,8 and I have written a fortran code to put them in order as below:
program gap
implicit none
integer:: i, j
do i = 1,4
do j = 6, 8
[Code]...
I want a space once every row loop has finish.I am dont know how to write the data as shown above using the fortran code in this post.
View 2 Replies
View Related
Jun 4, 2010
I have a data set that takes the form...
0.0 43
12572.9102 80.8521 263.3575 0.0200 12.6358 -86.4942
4.3870e-06 -0.3547
[code]....
View 1 Replies
View Related
Nov 21, 2010
I have:
Code:
C:u002Cdatau002CDocuments
If I used:
Code:
sed 's/u0052//'
It only removes the first occurrence. How can I remove all occurrence in the line?
View 5 Replies
View Related
May 8, 2010
I am trying to remove all the files in a directory hierarchy which a certain string inside the file (not the file name, it is the file content).
I can list out all the file name which has a string in the file using 'grep -r -l mystringlooking for'.
But how can I remove all the files returned by the grep ? I am trying this on ubuntu.
View 1 Replies
View Related
Jul 27, 2011
I would like to remove a string pattern which like this.You should not remove this /*This is the part should remove*/ You should not remove this.I would like to remove all the text inside the /* and */.
View 2 Replies
View Related
Feb 17, 2010
How can you remove files containing a specific string?I have...Code:find |grep 'string'This may return several results and I wanted to rm the results.I also have...Code:ls -l |grep 'string'|awk '{print $9}'which also may return results.But point is, I can't supply the results as a parameter to rmI was thinking of looping but I don't know how to access the results as if they were an array or something.
View 5 Replies
View Related
Mar 20, 2010
I have been fighting with a sed statement trying to get it to remove everything in a string until the last match and have been failing badly. how to get this to work..
sed --> enterprises.9.9.171.1.5.2.1.1.5
returns 5
I want sed to strip everything out until the last period. The final digit can and will change. Some parts before the final period can change as well, since enterprises will sometimes also be represented as more numbers and periods.
View 6 Replies
View Related
Aug 18, 2010
I have just switched to banshee as my media player and imported my films and music. Problem is, the video list is quite hard to read because all the video files have spaces in their names which are replaced by % signs, numbers and letters. I'm wondering if there is a command I can use in the directory that will automatically remove all the spaces from the filenames or better still, replace the spaces with hyphens or underscores?
View 6 Replies
View Related
Sep 16, 2010
the preceding and trailing spaces around the commas in my CSV without destroying my address field. I'm new to regex and sed so this is probably easy but I just can't do it without destroying the Address section. I'm using vanilla Linux and sed 4.1.3I'm willing to use any regex or even awk if needed.
Example:
I need this
randall , dean, 11111 , 1309 Hillside Ave., Warsaw, VA , 23591
[code]....
View 11 Replies
View Related
Mar 7, 2010
How could someone remove all double or more spaces from a group of words? Is there a GUI program or CLI method or both? Example: I like to turn this:
[Code]...
View 2 Replies
View Related
Sep 18, 2010
Im using this unix command(in a php file) to remove a certain string and then remove the whitespace left by that string. Unofrtunately in many cases, the files get completely erased. Is there a workaround?
Code
<?php
$dir = "./";
$rmcode = `find $dir -name "*.php"
[cod3e]....
View 14 Replies
View Related
Jun 8, 2011
How to remove all foldernames which contains spaces in Desktop with a single command?
View 7 Replies
View Related
Oct 4, 2010
I need to list the files only from 23:00 to 23:30 on 3rd oct 2010 from a directory and then zip them and have it.how to execute the same.
View 5 Replies
View Related
Apr 19, 2010
in gcc how to read a blank line ie a string of length 0.my code:
Code:
#include<stdio.h>
#include<string.h>
[code]...
View 3 Replies
View Related
Nov 2, 2010
I am running Ubuntu Netbook Remix 10.04. I have been having some problems recently with Pulseaudio, which has traditionally worked fine for me on this netbook actually. Specifically, when I boot the computer, the system will play the "Bongo roll" sound at the GNOME login screen, telling me that sound hardware has been detected and should be working fine.
Yet when I log into the Netbook interface, my volume notification icon has the three blank lines indicating my session does not have access to the sound hardware. Nor do any of the built-in Sound preference panels detect my hardware, only registering dummy output. Finally, the (hopefully) deprecated PulseAudio Device Manager and Volume Control applications also fail to detect my hardware.
However, this problem is inconsistent! It will only happen on certain boots, though the number seems to be hovering around 75% of boots where pulseaduio fails to load correctly. The daemon/service is running, and restarting it only returns:
jmmcl2@unteer:~$ sudo service pulseaudio restart PulseAudio configured for per-user sessions ask again, why is my Pulseaudio being so selective about detecting my sound hardware in Ubuntu 10.04?
View 1 Replies
View Related
Jul 28, 2009
selectively archive the subdirectories of a single parent directory in which said subdirectories have creation year-date 2008 and older.
View 5 Replies
View Related
Jan 1, 2010
I have a string of files named recup_dir.1 thru .66. I have the command sudo rm -r /home/"name"/Pictures/recup_dir.1 to remove them one at a time, how do I remove 20 or thirty at one command?
View 5 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
Oct 12, 2010
How can I remove this string from all files. I am not sure how it did get there
PHP Code:
<?php /**/eval(base64_decode('')); ?>
I tried this but It did not work
PHP Code:
find . -iname *.php* -exec sed -i 's/<?php /**/eval(base64_decode('')); ?> //g' {} ;
View 4 Replies
View Related
Jun 5, 2009
I have a text file which include code...
I mean, this string should be removed from each line and save in another file.
View 9 Replies
View Related
Jan 30, 2011
I am reading strings from a file using readline() function,the file contains some strings which has only special characters, I need to avoid the strings which has only special characters, the special characters are not similar. How to do it in python.??
View 2 Replies
View Related
Apr 2, 2011
I want to replace a string of directory path in a string to empty:
Code:
But this doesnt seem to give me the desired thing:
Code:
This gives the desired outcome, but its specific, i need a variable in the sed not a string. And if I replace STRING="/mnt/sda1/record/$dd/" then I cant use it for something else, cause its has all the weird backslashes now.
View 3 Replies
View Related