I want to split file foo into two parts, and I only intersted in the first one. But the N bytes in which the first part consists, I want it to be an exact replica of the corresponding bytes of foo. More exactly:
Im trying to read a file in c++ and search for particular character for example if this is a list that I have:
Alice Bob David
if the input is D, it should give David, if its B, gives bob. so in this case, meaning it reads the first character of every line. but if possible I want to make this dynamic so the user can specify which character position he is looking for, so in case he is looking for R as character index 3 in all lines, it should give Charlie. but the problem is, it does now recognize , besides, I do not know how to specify the character position in each line.
I want to be able to find the lines that matches my input and change the N to a Y, but only for the lines that matches the name and not any other N's My problem is the line does not always contain a P as it can be a D as well so my matching did not work. If my script issues the name $1=triva the lines will change to:
I have the following code so far but as you can see it does not change the D's
sed -i 's/trivia:P:Y/trivia:P:N/g' servers.txt
*** UPDATE ***
should I be using a method as follows? I am still stuck on the changing all instances though.
$1=server sed -i 's/$server1:P:Y/$server:P:N/g' server.txt sed -i 's/$server1:D:Y/$server:D:N/g' server.txt
I have to delete a certain line of text from the a textfile via ubuntu's shell scripting.I have done research, and it seems that most people advocate the usage of sed /d option. sed makes does not edit the text file. Hence, most options I discovered involved the use of a temporary variable/textfile and then overwriting the old file with the temporary new file. Is there anyway whereby I can bypass the use of temporary storage containers? I hope there is any magical combination of commands to edit the file directly.
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.
I am bouncing a file across platforms (windows->solaris->mainframe), and the file is starting out with a "special" character (the registered trademark "circle R") in some of the records. This character is not in the EBCDIC character set on the MF, so it is unrecognizable. The MF developer I am working with asked if it is possible to replace the character with a specific hex value (AF) before it gets to the MF.
I was putzing around with sed, tr, etc. on the ksh command line, hoping to find an easy way to get one of them to substitute hex instead of ASCII. I have found that the usual shell utilities recognize the trademark character, so homing in on what to replace is solved. But I cannot get anything to actually substitute in the hex sequence I want. E.g. I was thinking something like...
>cat special_file | sed 's/R/AF/g'
But my version of sed does not seem to have hex "editing" capability.
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?
I need to insert 3-4 lines of text to the beginning of a text file. The file is a largish MYSQL dump, the result of a backup shell script. This shell script should insert the required text.I've wrestled with sed, but lost.
I want to display something in my text view widget in glade using c code. that's all right. now I need to attach a save button beneath the text view.so that on click the text view content should save as a txt file..
So, while displaying the contents of above file on a web page, I want to format the field names found in the log file: User Name:, Reported Problems Description:, and Remarks:. These fields may contain a variable length of text and no specific line number is assumed for them to appear on.
I am trying to create a shell script, on taking a input file as parameter, which need to do 3 things
1) create a copy of existing file.
2) add a new line to the copied file.
3) strip off all the absolute paths inside the copied file
The first 2 points are straight forward. but i am finding it difficult to acheive the 3rd point. myself not very good with awk and sed. but gave it a shot in vain. For example, the input script consists of below,
Just using shell scripting, how can I insert text into the middle of a file name. The file has a predictable pattern, let's say 3 letters and 3 numbers and I want to insert text in the middle of those 2 patterns. Say ABC123 is the file name. As a result, the file name should be ABC.blah.123
I want to write expdp output in a text file using a shell script
If i write like below:
It will write whatever is there in log file to text file
But, sometimes export fails with out start taking export (without generating log file) because of job already exists error. such times, we dont know about that error until we check manually... so i wrote like below:
But still it is not writing anything in to text file using above stmt...
I have a problem with file names changes. I have a hundred of file with same names and different subdirectories. I want to change that file names by their subdirectery names.
Currently is: file name------------------------subdirectory name 1_km_16_days_EVI_s2_01200_01200.img --> MOD13A2.A2000049.h23v03.005.dir 1_km_16_days_EVI_s2_01200_01200.img --> MOD13A2.A2000065.h23v03.005.dir 1_km_16_days_EVI_s2_01200_01200.img --> MOD13A2.A2000081.h23v03.005.dir ...
I want to MOD13A2.A2000049.h23v03.005.img MOD13A2.A2000065.h23v03.005.img MOD13A2.A2000081.h23v03.005.img
I'm very new at Bash scripting and have a bone head issue that I'm trying (and failing) to resolve. I cannot get this one IF statement to work, it seems the comparison operator does not think the resulting number from the $b*$c+$b operation is an integer even though it is a number. Below is a small proof of concept script with the bit I'm having trouble with.