I wrote a hack script that outputs the following every so often: Code: 01/04/11 10:33:02: 97,1413,1447,2860 I must leave the data format the same --but I want a special number from it. In this case it's 97 and it's always going to be the first in the 4 columns of comma delimited items. I can extract with this:
Code: cat datafile | awk -F" " {'print $3'} | awk -F"," {'print $1'} But that's really sloppy. Can someone point out a better way of doing this (with awk) and tell me why?
Lately I've been needing to delete new untracked files from my versioning system. Being in linux I use: hg status -un|xargs rm And it works nice, but when doing it in windows, hg status lists paths with backslash so that is where stuff goes wrong. So then I try: hg status -un|sed 's/\///g' ...but I get the error: sed: -e expression #1, char 8: unterminated `s' command
Then I try some ascii: `hg status -un|sed 's/o134/o57/g'`...that gets me: sed: -e expression #1, char 14: Trailing backslash And some scripting: hg status -un|sed 's/`echo `/`echo /`/g' ...that gets me: sed: -e expression #1, char 19: unknown option to `s'
I try all the last with any other characters and I get the expected output... so I'm completely lost. I have cygwin, of course, and I want to avoid using a file (that is what I've been doing).
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...
On windows I really only used Notepad++ as my text editor, it had two features that I loved.What I need to accomplish is what I would do with Notepad++ column editor.I could have like 100 lines, and place the cursor at a column, and goto edit>column editor, and I could insert an incrementing number. (I could also pad the incrementing number with 0s, this was GREAT for making batch files among other things.)So each line at that column had a number higher than the previous line.The other feature that I used sometimes was a search/replace with regex patterns.Does anyone know of an editor that has those features for linux? I am mostly after the column editor insert feature but if you know of one with both features that would rock.
I would like a command or a bash script that search all files in all sub, modified last 12 hours, in /var/logs and that contains "alfa" or "bravo". The output should be filename of the file or files that contains that.
find out a command to search among all *.dat files in a certain path (including subdirectories) looking for the following text in them:
Code:
-------------------------------------------------------------------------------- Elements with small area Element Adjusted nodes --------- -------------- 16294 NO 17889 NO
and getting the list of elements with small area printed in a file "ErrorEl.txt". The output should have this form:
"/path/01/A.dat bad-el#01 bad-el#02
[code]....
I know already how to find out the dat files containg a certain string
Code:
c=/path/ grep -R --include="*.dat" "Elements with small area" $c | cut -d: -f1>> ErrorEl.txt
but I don't know then how to get the element numbers(16294 and 17889 in the example above)
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.
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.
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
[Syenite] RegionUUID = 8fc56fdd-0afd-4074-9432-0ae8f42b799f Location = 9992,10007 InternalAddress = 0.0.0.0 InternalPort = 9000 AllowAlternatePorts = False ExternalHostName = 71.171.21.9 What I need to do is find out what the IP address is after "ExternalHostName ="
After that I will need to compare that IP to whatismyip and if it's different then replace it but that is easy to do with sed. I just can't figure this simple hurdle out.
I want to run a script that runs after every 15 minutes that i will do using crontab. But in script want to search a string from the last 15 minutes logs in log file containing data of whole day.
how i can search the string according to time difference that is logs from from current time and current time - 15 minutes.
Sample logs are as follows:
26-Aug-2010 16:38:46,055|9172310750|subscription_app|31ba267e%3A12aadd47bdc%3A50e9|ChargeAmount|ChargingIntercep tor - subscriber details processed sucessfully- {arg0.referenceCode=balanceEnquiry:true;subsChannel:Unknown;channelType:Subscription;transactionId:3
But the problem is that in this case i just wanted to append "/home/dest" for which I could easily escape "/" with just two "", but I wonder if i have a long path like "/a/b/c/d/e/f/g/h/i/j" I will have to escape so many /. Is there any other way by which I can avoid escaping forward slash.
I tried following:
But receiving follo error
Bareword found where operator expected at -e line 1, near "s/destination-path=/'destination-path=/home" syntax error at -e line 1, near "s/destination-path=/'destination-path=/home" Bad name after dest' at -e line 1. tried with enclosing in double quotes as well but in vain
Back to the problem: I wrote a little bash script that people around here can run to search and replace strings in the current directory and all subdirectories. However, whenever there is a space in the new string (the one doing the replacing), I get this error:
Usually if I have to replace a character in a string I used the sed /s/ command. However, I am having some difficulty in doing the same thing when I have the following string in a variable in my shell script and I need to replace all the forward slashes ("/") to backslashes ("").
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.
I'm looking for a simple text editor which could highlight all occurrences of search term in the opened text file. This is a feature that I particularly like in the Windows Notepad++ editor where any selected word is automatically highlighted in the rest of the document.
i was wondering if in all the editors/tools in linux, if there was a prog that can extract a portion of a text file, giving it a starting line of say o as the first character on a line of say o35565 oxxxxx then when it finds the next line down the file with the same thing oxxxxwhatever
it could take those lines and all the lines between them and save it to another file? i dont know if you call this parsing? or what.
The dconf-editor is missing 'percentage-action', 'percentage-low', 'percentage-critical' strings that's responsible for notifying the user of the battery levels. How can I add them?
I have a few items in the Menu that refer to the start scripts of extracted Java programs that came as tarballs.Go into the Menu Editor and rename one of these (e.g. to reflect an updated version)Save - Message says "Updating System Configuration"Browse using Lancelot - the old name is not there but the new one is.Search using Lancelot - the new name is not there but the old one is.The new name is only in the search after reboot.Is there anyway to get Lancelot to update the search index straight away after a menu editor change?
I have a mail.log file, of which I want to redirect only the search strings of the sender from=<example.sender@exampledomain.com> and the size size=4537 to a file.
In every case the sender string starts as from=<> and the size string starts as size=
What would be the grep command to redirect only the two search strings to a .txt file?
I'm trying to search all .log files in ~/.irssi/irclogs/ and it's sub directories for the string 'irssi' and I had though the command I'd used for something similar before was.How should I edit the command, and is it possible to output every line found containing the string to file?
how to search for those files which contain word "AM_COLLECTION=22". I need to know all the files with this string. ( I know the grep command can do it but either
how to search for a specific string of text inside an html document. I then want to cut out that specific data that the field or string contains. I want to do a shellscript that makes this function automaticly.
For example:
# #Here i want to find the field "town" inside the html/java and then cut #out the town name from it and paste that to an file. # #
im tryin to make a tool in visual C++ which will take an input string through a text box,then it will compare tht string with a text file containing data and display the matched results in list box.