I want to make a batch file that will ask user for input, than write that input to a specific position in an already written txt file(called commands.txt which contains query) and call sqlite3 < commands.txt
I need this so inside the commands.txt where the query is, in LIKE 'userinput' i will add the users choice (parameter)
Although your question is not really specific enough and verging on the kind of inappropriate question that for stackoverflow (it does not include code), as hinted at by the comment, I'll take it at face value and assume there is much you need help with.
First let me deal with the question "I need to make a batch file"
A batch file is a simple text file with the extension .bat. You can create it with a text editor like notepad. We do not know what kind of system you have (Windows, linux, Mac etc) but lets assume Windows as you asked for a batch file. We do not know which version of windows (7 or 8 etc), So I'll try and be generic.
All windows machines come with a simpe text file editor called notepad. You can open this by typing notepad into the search box on windows 7 or 8. Lets start with a simple batch file:
:: This is a batch file
#echo off
echo Hello World
exit /b
Type (or paste) those 4 lines into notepad. Now select the file menu and select Save As, now in the Save As Type: selector choose All Files. In the File name: box type the desired name with the bat extension, such as doit.bat. Ensure you choose a suitable directory to place your new batch file. Leave the encoding as ASCII. Click Save. You have now made your first batch file.
Now you need to execute that batch file. Using the Windows File Explorer find the folder where you saved that batch file. While viewing the folder, hold down the shift key on the keyboard and then right click in the background of the folder and select Open Command window here. You will now have a command prompt window. You can now execute your new batch file by typing its name doit. It will display:
Hello World
OK - Now you have created your first working batch file.
Now for the next part; Asking the user for input. This is done with the set /p command. Add this to your batch file (before the exit line):
Set /P Like="Give me your input: "
echo Your input was: %Like%
That has solved the second part. Now the third part, edit the commands.txt file. If you do an internet search for a similar problem (editing files in batch files) you might find this help page: http://www.ousob.com/ng/edlin/ng96d9.php. This shows a generic way of changing any text string to any other in a file using EDLIN from a batch file; unfortunately EDLIN (and EDIT) are no longer included in windows so these batch files are not much help.
A search of stackoverflow finds similar queries which contain an answer for you.
So now you have all the parts of the answer:
How to make a batch file
How to prompt the user for input
How to replace lines of text in the commands.txt
You should be able to put it together and get it to work....
Related
I have a simple issue with zsh. Sometimes, I am in a directory with multiples sub-directories.
So, when I do a $ ls[TAB] or $cd[TAB], I list all these sub-directories.
But how to accept one of the suggestions for sub-directories? Is there a short cut or a key to choose a directory to go deeper in this directory.
I must precise that I don't know systematically the content of these subdirectories, so I can't often choose a subdirectory in which the first letter of filename could allow me to choose automatically the sub-directory to explore.
I was looking for a solution on the web but documentation about zsh completion is pretty big.
Edit: simplest solution to accomplish the desired effect:
press [/] key to 'accept' the current suggested directory ; then press again [tab] key to show suggestions of its subdirectories
Old suggested solution:
Install https://ohmyz.sh/
Then pressing the [tab] key displays a list and the first item is highlighted.
Hit the [tab] key again to choose the desired item and hit the [enter] key to write it in the command line interface, without actually executing the command, only as if you have just typed it in.
Then you can continue hitting the [tab] key to select another subdirectory, and so on.
It also works on any autocompletable, not only dirs.
The only way I know is: double click your target + cmd c + cmd v and then press Enter.
I know I have a file called 'mwc-fab' in my dependency,
so How can I search this file with the file name?
In vscode, i just type mwc with my node_modules file select and I get the file I want.
If you're using a Windows computer the command is Ctrl+T or Ctrl+P and on Mac Cmd+T or Cmd+P
https://flight-manual.atom.io/getting-started/sections/atom-basics/
There is an Atom package named incremental search that you can use to search thru open files. After installing incremental-search you can type command-i and this opens a text box near bottom of screen where you can input your search string. After that you can command-i repeatedly to go to next matching string. Be sure to read the directions for more useful commands.
My rmarkdown code produces a html document. This document lists out the process that needs to be followed by front line staff at month end. The process flow requires users to open xl files, update a few fields (such as report month etc) and then run macros.
I have used hyperlink to the original XL files as follows
[click to opel xl file](path/and/file names)
The above link opens the original file and the user is able to
overwrite the original file, I don’t want this to happen.
I want the hyperlink to generate a new file that would be downloaded
so that nothing happens to the original file. How to do this?
Please could you kindly help me out.
Thanks in advance
After extensive research, this can't be done using conventional rmarkdown!
Let's say I have a directory with the following contents:
/Project.Presentation
/Project.Presentation.API
/Project.Presentation.Web
/Project.Presentation.Infra
/Project.Presentation.Util
I want to do this -> Project.Presentation: API and let it autocomplete to Project.Presentation.API. Inside Project.Presentation to type API and <tab>.
Is it possible to let zsh use this 'forgiving' way of ?
You're overcomplicating your solution.
If you want to execute a command with a file inside these directories, or just cd in one of these directories.
Just write cd (or other command) first, then press tab that will complete Project.Presentation. then you can either write API or write A and press tab.
By the way, you can have a way to navigate through the possibilities with an extra tab key.
Read man zshoptions for to discover options available in zsh.
I am working with vim. I created a new cpp file using
vim xyz.cpp
After opening the file, I added some basic includes and comments. Then I closed it(:wq!) and re-opened it only to find that I am not able to delete/edit the previously written commands, even after pressing i (for insert), although it gets into insert mode and I am able to add new text to the file. I must say that when i am NOT in the insert mode, then I am able to delete individual characters by pressing x . But it doesnt solve my problem.
I checked the file permissions and it says -rwxrwxrwx, so I dont think permissions is the issue. Has anyone faced this problem before. Any kind of help will be appreciated.
Thanks
:help 'backspace' is your friend
Influences the working of <BS>, <Del>, CTRL-W and CTRL-U in Insert
mode. This is a list of items, separated by commas. Each item allows
a way to backspace over something:
value effect ~
indent allow backspacing over autoindent
eol allow backspacing over line breaks (join lines)
start allow backspacing over the start of insert; CTRL-W and CTRL-U
stop once at the start of insert.
When the value is empty, Vi compatible backspacing is used.
Try to set it to
set backspace=indent,eol,start