Ok, I have a script with a commandline option that allows the user to add a custom function to the script file. I have tried everything in my limited knowledge of sed to get this to work and keep coming up short. I need sed to search for a line starting with a pattern, I've got that part so far, but now I need it to write to the line directly under it with an argument passed to the script. Right now i have several commandline switches being handled i want the -i switch to allow a user to add what comes next to the script. ex:
should append 'test' to the file and save changes. Kind of like in javascript where you can .appendChild and such. There's a line that starts with foobar that i'd like sed to do this: find the line starting with foobar in myscript.sh and append test after that line. A subsequent 'cat' or 'vim' of that file should reflect test has been appended. I'll even use awk if that's a better answer. Find foobar in myscript.sh and add test after it and save the changes.
---------- Post updated at 12:43 AM ---------- Previous update was at 12:39 AM ----------
oh geez I should have just tried one more time. ---------- Post updated at 03:41 AM ---------- Previous update was at 12:43 AM ----------
ok i've got sed working almost as needed. In my script i have two occurrences of "#CUSTOM", once in the sed command and once as a comment. I need sed to edit the script that its in and do this:
But not append it after where sed is locate. Let's say where I want it to append to is line 50, or even just say "the second occurrence".Basically I'm letting the user edit the calling script and add a directory I get from them which i want to become $aVariable. Please help I've been messing with sed all night now. It's either given me a line after both or when i tried some example i saw online it appended it after about 50 lines.
---------- Post updated at 03:54 AM ---------- Previous update was at 03:41 AM ----------
ok fixed the occurrence issue with
before #CUSTOM. I still can't get variables working. Anyone?
---------- Post updated at 04:07 AM ---------- Previous update was at 03:54 AM ----------
nvm fixed it on my own...lol...forgot about the stupid single quotes variable expansion. use " "
I am trying to create a bash script that will create new function by using the user input. The below will create the necessary files in the correct format, however when it comes to the # create function I am at a loss.
If the name entered was NEWNAME and the genes were GENE1,GENE2 then two files... (0 Replies)
In the below bash a file is downloaded when the program is opened and then that file is searched based on user input and the result is written to a new file.
For example, the bash is opened and the download.txt is downloaded, the user then enters the id (NA04520). The id is used to search... (5 Replies)
Hi All,
I have a UNIX script which reads "PxyType" (read PxyType) as input from user and a file (eg : "File.json") with the list all PxyType's.
Based on the user input for "PxyType" in "File.json", I want to redirect each matched line to a different file ("File1,2,3,..json").
Can you... (7 Replies)
hi all
i'm new in shell scripting and now i'm working on project and i wanna make a function take input from user and test it's datatype then if correct write it to file
i wounder what is the best way to do this ?
can i use awk ?
edit by bakunin: Please give your threads a meaningful... (5 Replies)
Dear All,
I would like to find an automatic way to add a given code which belong to a class at the end of the column , for example this is my input file:
0610009O20Rik
V$VMYB_01 310 (+) 1 0.971 v-Myb
V$EVI1_04 782 (-) 0.763 0.834 Evi-1
V$ELK1_02 1966 (-) 1 0.984 Elk-1... (4 Replies)
i have a script which takes input from user, if user gives either Y/y then it should continue, else it should quit by displaying user cancelled.
#!/bin/sh
echo " Enter your choice to continue y/Y OR n/N to quit "
read A
if
then
echo " user requested to continue "
##some commands... (7 Replies)
Hello I would like to ask for help with a script to search a directory that contains many log files and based on a users input after being prompted, they enter a date range down to the hour which searches the files that contain that range.
I dont know how to go about this. I am hoping that the... (5 Replies)
Hi,
I have below line from the config file
$__MR_CONFIG = 'userinput';
I want to get the value from the user for the "userinput" and then append the full line to another file.
Can you please let me know how can I proceed on this? I am new to unix and your help is greatly appreciated.... (3 Replies)
Hi,
I have a file which have set of rows and has to create separate files based on the id.
Eg:
001_AHaris020
001_ATony030
002_AChris090
002_ASmit060
003_AJhon001
Output: I want three files like 001_A.txt, 002_A.txt and 003_A.txt.
001_A.txt should have
... (1 Reply)