Software :: Check The Contents Of A Text File For A Specific String And Remove It From The File From The Command Prompt?
Oct 14, 2010
I want to be able to check the contents of a text file for a specific string and remove it from the file from the command prompt. I would basically be searching through a number of files and if a specific string is found I would like it removed automatically. pretty much a find and replace, were the replace is nothing. any one got any ideas on how you would do this. I already have the search part sorted just need to be able to remove the string I don't want from the multiple files.
I am not especially cli adept so could someone tell me the best way to use the diff command to get the difference between a string of text and the contents of a file instead of between the contents of two files?
I have Ubuntu 9.10 installed on my HP desktop, but I'm running an older version (8.10) on a live CD so I can at least get online to ask for some When I tried to log on earlier it went to a command prompt and said the 'file system check failed' and to run fsck manually. I entered 'sudo fsck' at the prompt and I selected "y" to fix all the bad inodes, when it was complete it told me to restart, I then entered 'sudo restart' at the prompt and it said 'sudo uuid unknown'. I have not installed anything recently and I'm not sure what to do.
I've created a new group and a new user called dftp... Now I wanna do one thing... If 'dftp' connects thru ftp he should be directed to a particular location... and he shouldn't be able to see other folder except for his own including the parent folder that contains that location... I changed dftp's home folder to the location I want. However while connecting thru ftp. user dftp has been given permissions to see other folders and check out the contents of the other folders.
i am writing a script for my ubuntu server and basically i want it to download a file that i specifically type in then take that file put it in a certain folder (note file may or may not be archived so i'd have to check for that) then add the name of that file to a text file.i know sounds strange but this is what i got so far:
Code: #!/bin/bash echo "-----Star of Script-----" echo "Please enter URL:" read URL cd testdir wget $URL //extraction here + delete original archive (rar,zip,anything :S) echo name_of_file >> list.txt echo "-----End of Script-----"
I have a script that among other things generates a makefile with an error that causes make to fail. specifically, the string "-Wimplicit-function-dec" should be changed a bit to "-Wimplicit-function-declaration". Is there a way to have bash add the new eight characters in the right place (on line 105)?
How can read the file /var/etc/allInOne.cfg and distribute its contents on multiple cfg files using C language. /var/etc/allInOne.cfg contain the data and the path of each text file.
The source file "/var/etc/allInOne.cfg "look like this: line1 line2 ... line10 filePath:/var/etc/file1.cfg line12 line13 ... line14 filePath:/var/etc/file2.cfg linen .. filePath:/var/etc/filen.cfg the result will be :
The expected result is: /var/etc/file1.cfg will contain line1 to line10 /var/etc/file2.cfg will contain line 12 to line13 /var/etc/filen.cfg will contain linen to linen-1
I created a bash script to help me mount my network shares.However when I link the file to the desktop and dbl click on the link it asks me if I want toCode:RUN IN TERMINAL - DISPLAY - CANCEL - RUNHow can I get it to RUN IN TERMINAL each time I dbl click it?
[Syenite] RegionUUID = 8fc56fdd-0afd-4074-9432-0ae8f42b799f Location = 9992,10007 InternalAddress = 0.0.0.0 InternalPort = 9000 AllowAlternatePorts = False ExternalHostName = 18.104.22.168 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 am looking for a way to keep a log and make if then statements if a line exitsts in the log. I also am looking for a way to make a simple loop, like goto line number, and I also am wondering how to add/remove bits of text from a text file (plugins line in server.properties)
I am having trouble writing a script that monitors a text file. When the file contains number 1 (or any other string that is not a command) it does nothing, but when it is something different from 1, it executes that command.
So, there are 2 files: monitor.mon - this is the file that will be checked constanlty; and test.sh - the script that does the job. The monitor.mon file will have its content modified by php. This means a web page will have a form where I input commands and writes does commands in the file. Test.sh will watch when the file's content changes from character 1 to a command, execute that command and write back a 1 so it will not execute it more times.
I tried combining while and if but with no success. Tried reading the file with cat and grep -e but it doesn't seem to recognize when content changes.
I have large text files with space delimited strings (2-5). The strings can contain "'" or "-". I'd like to replace say the second space with a pipe. What's the best way to go? Using sed I was thinking of this: