I’m trying to replace the next string with sed in all the files in the current directory : (including apostrophe) ‘Control_Reports_Pg.C_Table_Title_Date’ with the string : timeofday()::varchar(250) I tried to escape the special characters ‘ ( ) with the command : The error I got : sed:…
Tag: linux
Removing carriage return character ^M from output file created by python script
I have a python script that outputs file with similar text: This data is split by “” and is imported to a table in hive database. My issue that some of that data contains ^M carriage return character which splits up my data: I need to remove ^M and have my data all together. I have tried dos2unix …
Read the log files and get the entries between two dates
I want to extract some information from the access log file that matches a keyword and between two dates. For ex. I want to find log entries between two dates that contains text “passwd”. For now, I am using the following command but not getting the correct results: Date format is [22/Feb/2017:17:…
How to get local codepage in linux?
In Windows, I can use GetAPC function to get the local codepage. But how should I do to get local codepage in Linux? Thanks. Answer Linux does not use code page identifiers. It has locale identifiers, but different processes can have different locales and a process may be using different locales in different …
Problems establishing connection with DB
Platform: LINUX. I am a beginner of MongoDB and pymongo. After installing pymongo, here is a simple test I tried on ipython: At this point, it chokes. And in the end, spits out a “Error 111: connection refused” error. So, I tried invoking MongoDB straight from the terminal and I still got the erro…
Linux shell script regex match
I have a text file. I want to get lines starting with specific format. I just want to get lines that have x/x/x format. x is a number. But this regex is not working. It is always giving no match : File is : Answer Don’t use bash if you can use a better tool: But if you have to
how to handle bash with multiple arguments for multiple options
I need to download chart data from poloniex rest client with multiple options using bash only. I tried getopts but couldn’t really find a way to use mutliple options with multiple parameters. here is what I want to achieve having the arguments I need to call wget for c x p times well I am explicitly wri…
Issues importing python-pptx on Linux (Ubuntu 17)
I am trying to import the python pptx library in a python programm. I installed it using pip before, which gave me the following output: So this seems to be a success. But as I am trying to import the module using the following code: It says No module named ‘pptx’. It must have something to do wit…
Adding newline character to printf() changes code behaviour
For some reason, adding n to printf() changes the behaviour of below code. The code without n prints (null) whereas the code with n leads to Segmentation fault. Printf.c Printf.c – Output Printf_Newline.c Printf_Newline.c – Output I am curious to understand the reason behind this. Answer Both are …
pipe command make standard input broken
I have two processes: t1.cpp and t2.cpp. t1.cpp and t2.cpp are simplified ,I want to describe the problem easily. After compiling t1.cpp and t2.cpp. I execute them in this way ./t1 | ./t2. Problems occur! cin >> x; in t2.cpp failed! I have no chance to type from the keyboard. It seems the pipe command i…