All Questions

Filter by
Sorted by
Tagged with
2
votes
3answers
43 views

Replace text in between certain pattern in UNIX

I want to replace the Millisecond field from file with ":" patter to "." pattern. Input:- Jun 12 2018 3:33:49:000PM Jun 12 2018 3:33:49:850AM Desired Output:- Jun 12 2018 3:33:49.000PM Jun 12 ...
0
votes
1answer
39 views

set alias to read variable and then use in second command; only works when I execute them manually

I am with CentOS 7 and I want to bind an alias to launch PostgreSQL shell(psql). I defined this alias and append it in /etc/profile.d/alias: alias psql-local="read -p \"PSQL: enter the DB to connect: ...
0
votes
1answer
367 views

How can I start a service after PostGres has booted?

I'm using CentOS 7. I have a nodeJS server I want to run as a service, but I would prefer the service started after my PostGres 9.6 server had booted. I tried specifying after in my service ...
-1
votes
1answer
997 views

How to pass a list to psql on command line?

I'd like to know if there's a way do so something like this : lab-2:/tmp# echo 46692,46694,46696,46704,46708,46709,46713,46730,46736,46574 > deletelist.txt lab-2:/tmp# cat deletelist.txt 46692,...
1
vote
4answers
1k views

Linux - how do I ignore special characters between “ ”?

My file: (1 sample line) MMP,"01_janitorial,02_cleaning_tools",1,,CUBIC_INCH,"(14) tray capacity, 6" upright with 3" spacing, mounts on 48"W x 24"D, taupe epoxy, fits MetroMax i & MetroMax Q ...
4
votes
1answer
4k views

How to save psql error message output in bash variable?

I have a script that runs several different psql statements. I'm trying to capture the error output from psql when password entered is incorrect. The password is entered in before the check (and when ...
1
vote
1answer
526 views

Using input from two different files in a for loop

I have a list of files that I want to search across a list of database tables: [root@host hs]# head -n 3 tables rec_playinth120116 rec_playinth120216 rec_playinth120316 [root@host hs]# head -n 3 ...
1
vote
1answer
588 views

How to run pgpool(or any service) through postgres(any specific) user

I am trying to setup HA solution for PostgreSQL. For that, I am running pgpool service. In that service, it calls a script whenever my primary node fails by calling it like this: /etc/pgpool-II-94/...
0
votes
2answers
675 views

How to use sqlformat tool with pgAdmin

I am trying to add external SQL formatting utility to pgAdmin. There is an option available in pgAdmin3 in Preferences -> Query tool -> Query editor called external formatting utility I set up ...
2
votes
1answer
5k views

backup file locally in shell script

This is my crontab: crontab -e 30 5 * * * sh /home/donato/Documents/pg_bak.sh Every day at 5:30am I want to execute a shell script I created called pg_bak.sh. This is the contents of the shell ...
0
votes
1answer
2k views

syntax error: unterminated quoted string when using regexp_replace in bash script

I've added some code to the end of a bash script I am using. The code shown here is intended to copy a csv into my postgres table, and then remove brackets, quotes and double quotes from the title ...
4
votes
2answers
5k views

how to split long psql command in bash script over several lines

I have a long psql command to execute within a bash shell script, and I am wondering what the correct way is to split it across several lines? The standard Unix script 'split line' backslash ...
0
votes
1answer
348 views

How to run command after entering postgres

I am trying to execute ls after opening a new Guake tab and logging into postgres. guake -n guake -e 'sudo -i -u postgres && ls' The command successful opens a new tab then prompts me for my ...
0
votes
2answers
45k views

Shell script to execute psql command [closed]

I want to make an automated script to make a database user and password in Postgresql and also import some databases. When i execute my script bellow it stops somewhere and when i log out (CTRL+D or ...
2
votes
1answer
3k views

How to write a Shell Script using the condition from a database

Consider this is the condition I need to check select count(*) from nm.table1 where column1 =true; Now it should come out of the db (PostgreSQL) and use IF THEN ELSE LOOP in the Unix Something ...
0
votes
1answer
521 views

Postgres 9.0 linux command to windows command conversion [closed]

i am working on an application using delphi 7 as the front end and postgres 9.0 as the back end. I have to upload images to the server so i use \lo_import and \lo_export for inserting images on the ...