Questions tagged [unix]

The Unix operating system is a general purpose OS that was developed by Bell Labs in the late 1960s and today exists in various versions. Important note: This tag is exclusively for programming questions that are directly related to Unix; general software issues should be directed to the Unix & ...

0
votes
0answers
9 views

grep specific value to use as filename from data using awk

I have a file with data as below * sub : A 111 ------------------ * sub : B 222 ------------------- * sub : C 333 -------------------- I have to separate this data into 3 different files ...
1
vote
0answers
7 views

Using sed in Linux to extract lines from a log file

I have a log file which prints the following lines: 01:15:21.882 DEBUG [SampleProcess] Sample Message 01:15:21.882 DEBUG [SampleProcess1] Summary Report Sample Text1: 126 Sample Text2: 2330 Sample ...
0
votes
3answers
22 views

How to code sed to delete multiple lines after a keyword until next blank line reached

Can anyone advise me on how to code a sed script that can be used to update a text file as follows: Each time a line in the file containing the character string 'Header_one' is encountered: - delete ...
0
votes
3answers
30 views

Printing pattern in unix using awk

need to print log file as per the field data present in file using awk. Sample log file data-- Joe,4 Tony,2 Peter,5 Desired Output (First Field with c<0>---c-- Joe,c0,c1,c2,c3 Tony,c0,c1 Peter,...
1
vote
1answer
18 views

Creating temp directory in www for download CentOS

I need to create temp directory in a specific location under var/www/html so anybody can download it for a several mins. How can i do that? mktemp -d generates under /tmp/xxxxx
0
votes
1answer
26 views

expand unix variable inside sed command

I need to replace current value in configuration file with new value which is assigned to variable , like file_name=abc.txt needs to be replaced like file_name=xyz.txt where $file=xyz.txt I ...
0
votes
0answers
28 views

command not working properly: lolcat and sl

How do I make my train from the sl command look all rainbowy with the lolcat command? i.e. sl | lolcat
0
votes
1answer
22 views

Not able to access tables from a corrupted MySQL Dump file

grep -n "Table Structure" dumpfile.sql returns XXXXXX:-- Table structure for table `table_name_1` XXXXXX:-- Table structure for table `table_name_2` XXXXXX:-- Table structure for table `...
0
votes
1answer
20 views

how to assign the output of the command in unix [duplicate]

how can I assign the output of the below command to a variable in a while loop? echo $(( `date +%s` - `stat -L --format %Y $"/root/path/$output_file"` )) This command checks the age of the file in a ...
0
votes
0answers
10 views

Read autosys global variable in Python?

I want to pass some host name which set as a autosys variable to the Python script as an input variable ! I don't want to run autorep -M [variable Name] in my Python script Is there another way ? I ...
0
votes
0answers
7 views

Data Masking on huge CSV files stored in AWS S3

I have huge csv files of size ~15GB in aws s3 (s3://bucket1/rawFile.csv). Lets say if the schema looks like this: cust_id, account_num, paid_date, cust_f_name 1001, 1234567890, 01/01/2001, Jonathan ...
0
votes
1answer
24 views

Using parameter in unix function

I want to run a script using function. Script runs fine as is but want to run using function and pass something as arg #! /bin/ksh # # profile.ksh # # sample Korn shell profileument. ...
1
vote
1answer
22 views

unix echo string with underscore next to variable

Is there a way to use echo to print text containing underscore next to a variable? For example: $ var_name='foo' $ echo "$var_name\_bar" foo\_bar $ echo "$var_name""_bar" foo_bar I would like to ...
1
vote
1answer
41 views

sqlplus removes extra whitespace

I have a below test ksh file #!/bin/ksh ( sqlplus -s << EOF ${DATABASE} SET SERVEROUTPUT ON; SET HEAD OFF SET FEED OFF SET DEFINE OFF SET PAGES 0 SET COLSEP ";" ...
0
votes
0answers
21 views

xsltproc not modifying with template

I have a .xml file that starts with: <?xml version='1.0' encoding='UTF-8'?> <domain xmlns="http://xmlns.oracle.com/weblogic/domain" xmlns:sec="http://xmlns.oracle.com/weblogic/security" ...
1
vote
1answer
16 views

How to check TLS version of my Unix server [on hold]

We're trying to connect to a server but it's having the below error: Sep 26 11:00:38 server name[8660]: conn=******** fd=*** closed (TLS negotiation failure) I would like to know if the TLS version ...
0
votes
1answer
18 views

Check the logs and abort the jobs on the basis of the count received

For my code , I have 5 logs generated for 5 different tables . I have to find for which table the records are not loaded correctly . Logs generated NWPR_TempLoad_CSP_11.log: 0 Rows not loaded due ...
0
votes
0answers
36 views

Using pipes to communicate with multiple child processes that read from stdin

I'm struggling to properly understand fork(), pipe(), and execvp() and would like guidance on where I am going wrong with this code, and where I should go from here. From my understanding, if you want ...
0
votes
1answer
22 views

Search for keyword directly from shell and get count without saving logs into external file

I'm executing my jar file which will create logs in the shell. My requirement is to search for a keyword,directly from the shell,without creating a log file.Executed using this code `E:\Innoviti\...
0
votes
2answers
40 views

Extract multiple create table statement in hive

I need to extract create table statments from below code. #!/bin/bash rm -f tableNames.txt rm -f HiveTableDDL.txt beeline --showHeader=false --outputformat=tsv2 -u jdbc:hive2:// -n hive -e "show ...
0
votes
4answers
48 views

unix extract data from file

I've got a file.sql file from an informix database export. The following is a small part of the file (I changed the data a little bit to make it anonymous): grant dba to "xxx"; grant dba to "yyy"; ...
-1
votes
1answer
23 views

How to calculate UNIX timestamp difference using python? [duplicate]

I want the diff between two timestamps which are available to me as list of strings. date_list = ['Tue Sep 25 21:12:32 PDT 2018', 'Tue Sep 25 21:15:27 PDT 2018'] How do I get the difference in ...
1
vote
3answers
68 views

Is there a way to treat a single column of integers as an array in order to extract certain digits?

I am trying to treat a series of integers as an array in order to extract the "columns" of interest. My data after extracting a column of integers looks something like: 01010101010 10101010101 ...
2
votes
2answers
51 views

String values in | delimited field are getting split to the right in awk

While reading the 2nd Column from the given file I am facing issues while reading multiple columns using awk from the given file. While reading column 2 the contents are shifting to the right. /home/...
2
votes
1answer
117 views

Different behaviour about pthread_cond_wait on OpenBSD and Linux

I am testing the following code on both OpenBSD-current and Arch Linux (the kernel version is 4.18.9): #include <pthread.h> int main(void) { pthread_mutex_t mutex = ...
0
votes
1answer
39 views

bash exec command makes while loop too many times?

i have 2 text files 1.txt and 2.txt. 1.txt consists of names and ids separated by a tab, like so: Doe,John 123456 Smith,Jack 234678 Green,George987987 West,Mae 444555 2.txt consists of ids ...
1
vote
0answers
24 views

rsyslog 7 search and replace message content

In rsyslog I am trying to search for a certain keyword in my log message and replace with another but seem to be running in to an issue. Looked around and found very few examples of this but couldn't ...
1
vote
1answer
23 views

How to cut a string after last occurrence of a substring in shell?

For a string like this, "By using our site, you acknowledge that you have read and understand our Cookie Policy, Privacy Policy, and our Terms of Service." I want to cut the string from last ...
0
votes
1answer
38 views

Set Linux command alias for complex query [duplicate]

For testing purpose, I need to set up Linux command alias like this: alias 'dmidecode -t 1'='cat ~/test/system_info' But the alias command doesn't work like this. It seems that the alias name should ...
-2
votes
1answer
31 views

execute multiple command with jsch session and channelexec

I struggled to get this working but eventually got the script to execute a command (executing a sh script) on a remote unix server. I am trying to execute a second command and keep getting an error ...
0
votes
1answer
34 views

Unix - How to search for exact string in a file

I am trying to search for all files that contain exactly same id as listed in another file and put the file names in another file. I am using below command to find the files. grep -w -f SearchList....
1
vote
1answer
44 views

Read from pipe even if the write end is closed

my teacher said that if the writing end of a pipe is closed, the child process can no longer read from the read end of the pipe and a read would generate a BROKEN _PIPE error. However, I can't get ...
1
vote
1answer
24 views

Equivalent of ftp commands prompt and hash in sftp

When I use ftp to connect to other server, after connecting we are using below commands. prompt hash but now we have changed the process to sftp. If I gave the command prompt or hash after I ...
0
votes
1answer
17 views

File Transfer to Hadoop HDFS from remote linux server

I need to transfer the Files from remote Linux server to directly HDFS. I have keytab placed on remote server , after kinit command its activated however i cannot browse the HDFS folders. I know from ...
-4
votes
0answers
23 views

Read and Write in a log file continuously using shell [on hold]

Have a application log file, getting log details continuously written from Application. It keeps logging multiple details. Now need a standalone script, which will read this log file continuously and ...
-1
votes
0answers
8 views

Is there a tool to listen to a socket and tee the output to the STDOUT in a terminal and forward it to another listener?

Pretty simple idea that I'm sure somebody has come up with before. eg command1 | tee > /dev/tty | command2 but with sockets instead of pipes. I'm trying to listen to the communication between two ...
-1
votes
2answers
47 views

Extract text between two markers and replace a character

I want to change >lcl|ORF183:9482:8118 unnamed protein product into >ORF183:9482-8118 Keep everything after | and before 'white space', plus replacing second : to - So far I'm doing it with ...
-1
votes
0answers
22 views

C Check client disconnection

I'm trying to check when a client disconnects (closes connection) from the server. I know that when a TCP connection is closed on one side read() on the other side returns 0 bytes, therefore I could ...
0
votes
2answers
38 views

Exit early from the pipeline if there are no arguments to xargs

Say I have this pipeline: pgrep -P $$ | xargs kill -INT; sleep 0.6; pgrep -P $$ | xargs kill -9; what I want to do is avoid the sleep call if there are no arguments to xargs. Something like this: ...
0
votes
0answers
12 views

Variable within another variable [duplicate]

How Can I print a variable within another variable1=Hello ${variable1}_variable2=world echo "${${variabel1}_variable2}" should print : world I can store it into third variable and print it ...
2
votes
1answer
34 views

Using a loop to string together a list of variables with filenames

I have created a script that identifies a unique set of files (from a large list) and saves the file paths as unique variables (e.g. $vol1, $vol2, $vol3... see below). for volume in `seq 1 $...
-1
votes
1answer
38 views

log15 library rounds up epoch time from nanoseconds to seconds for logging

I'd like to have millisecond precision for my logging in my golang project, currently using log15 library Problem is when I append it to Context, it rounds back up to seconds newTimeWithMilliseconds ...
1
vote
3answers
50 views

Unix - Replace column value inside while loop

I have comma separated (sometimes tab) text file as below: parameters.txt: STD,ORDER,ORDER_START.xml,/DML/SOL,Y STD,INSTALL_BASE,INSTALL_START.xml,/DML/IB,Y with below code I try to loop through ...
0
votes
0answers
23 views

Removing non-printable characters with sed not working

I am working on AIX unix and trying to remove non-printable characters from file the data looks like in Arizona w/ fiancÃÂÃÂÃÂ in file when I view in Notepad++ using UTF-8 encoding. When I try to ...
0
votes
1answer
14 views

Want to run Post-deployment script only once in AWS

For codeDeployment script, we provide Before-Install, After-Install scripts. My requirement is to run After-Install script only once i.e. the script should be deployed on the server only for the first ...
0
votes
1answer
33 views

Sed and order patterns

I have a file that containes my target lines (start with '>') ... >lcl|1:c127-20 Ricardo3 phone I want to get : >Ricardo3:127-20 My steps: (1) Change ':' with ' ', (2) remove string 'c' and ...
0
votes
2answers
20 views

UNIX, find string in all files in sub directory with line numbers and filenames

I'm trying to do a recursive text string search in UNIX and have the results show both the filename and line number on which the text appears within the file. Based on some other answers here I have ...
0
votes
0answers
33 views

AWS CLI: How to get rid of start of string in bash [duplicate]

I'm moving a file between two folders in AWS. Using the CLI. I would like to pick Latest file and move it to a different folder. I solved the issue of picking latest file, however it gives me the ...
1
vote
0answers
26 views

java.sql.SQLException: [TimesTen]Cannot find the requested DSN (ormb_ttdb) in ODBCINI /var/TimesTen/tt1122/sys.odbc.ini or /var/TimesTen/sys.odbc.ini

I have setup a Timesten client(11.2.2.8.0) on my unix machine. I have setup a Timesten server on different machine. After setup is complete I am trying to connect to Timesten database using JDBC ...
-1
votes
0answers
48 views

Removing special characters from a string in unix [on hold]

How to replace just a given characters at the end of a string with certain other characters, leaving the beginning of the line unchanged, for example: In the string http://stack.kinokrad-co.com...