Search Results

Search found 4938 results on 198 pages for 'unix timestamp'.

Page 15/198 | < Previous Page | 11 12 13 14 15 16 17 18 19 20 21 22  | Next Page >

  • UNIX: Replace Newline w/ Colon, Preserving Newline Before EOF

    - by Maarx
    I have a text file ("INPUT.txt") of the format: A<LF> B<LF> C<LF> D<LF> X<LF> Y<LF> Z<LF> <EOF> which I need to reformat to: A:B:C:D:X:Y:Z<LF> <EOF> I know you can do this with 'sed'. There's a billion google hits for doing this with 'sed'. But I'm trying to emphasis readability, simplicity, and using the correct tool for the correct job. 'sed' is a line editor that consumes and hides newlines. Probably not the right tool for this job! I think the correct tool for this job would be 'tr'. I can replace all the newlines with colons with the command: cat INPUT.txt | tr '\n' ':' There's 99% of my work done. I have a problem, now, though. By replacing all the newlines with colons, I not only get an extraneous colon at the end of the sequence, but I also lose the carriage return at the end of the input. It looks like this: A:B:C:D:X:Y:Z:<EOF> Now, I need to remove the colon from the end of the input. However, if I attempt to pass this processed input through 'sed' to remove the final colon (which would now, I think, be a proper use of 'sed'), I find myself with a second problem. The input is no longer terminated by a newline at all! 'sed' fails outright, for all commands, because it never finds the end of the first line of input! It seems like appending a newline to the end of some input is a very, very common task, and considering I myself was just sorely tempted to write a program to do it in C (which would take about eight lines of code), I can't imagine there's not already a very simple way to do this with the tools already available to you in the Linux kernel.

    Read the article

  • Creating a child process on Unix systems?

    - by Hakan Svensson
    I'm trying to create a child process in another process. I am writing both the programs in C language. First I write a dummy process which will be the child process. What it is doing is only to write a string on the screen. It works well on its own. Then I write another program which will be the parent process. However, I can't make it happen. I'm trying to use fork and execl functions together, but I fail. I also want the child process does not terminate until the parent process terminates. How should I write the parent process? Thanks.

    Read the article

  • Find all words containing characters in UNIX

    - by fahdshariff
    Given a word W, I want to find all words containing the letters in W from /usr/dict/words. For example, "bat" should return "bat" and "tab" (but not "table"). Here is one solution which involves sorting the input word and matching: word=$1 sortedWord=`echo $word | grep -o . | sort | tr -d '\n'` while read line do sortedLine=`echo $line | grep -o . | sort | tr -d '\n'` if [ "$sortedWord" == "$sortedLine" ] then echo $line fi done < /usr/dict/words Is there a better way? I'd prefer using basic commands (instead of perl/awk etc), but all solutions are welcome! To clarify, I want to find all permutations of the original word. Addition or deletion of characters is not allowed.

    Read the article

  • Unix: How to use Bash backticks recursively

    - by HH
    Either I missed some backlash or backlashing does not seem to work with too much programmer-quote-looping. $ echo "hello1-`echo hello2-\`echo hello3-\`echo hello4\`\``" hello1-hello2-hello3-echo hello4 Wanted hello1-hello2-hello3-hello4-hello5-hello6-...

    Read the article

  • Unix makefile errors " 'ake: Fatal error: Don't know how to make (c file here)"

    - by gwenger
    I've written the below makefile: hw2p1: hw2p1_main.o hw2p1_getit.o hw2p1_parseit.o hw2p1_moveit.o hw2p1_showit.o gcc hw2p1_main.o hw2p1_getit.o hw2p1_parseit.o hw2p1_moveit.o hw2p1_showit.o hw2p1_main.o: hw2p1_main.c gcc -c hw2p1_main.c hw2p1_getit.o: hw2p1_getit.c gcc -c hw2p1_getit.c hw2p1_parseit.o: hw2p1_parseit.c gcc -c hw2p1_parseit.c hw2p1_moveit.o: hw2p1_moveit.c gcc -c hw2p1_moveit.c hw2p1_showit.o: hw2p1_showit.c gcc -c hw2p1_showit.c The first time I tried to call make, I got the error: "make: Fatal error: unexpected end of line seen" I deleted the blank lines between targets and called make again, but this time I got " 'ake: Fatal error: Don't know how to make hw2p1_main.c" I've compiled all of these files separately and then linked them so I know that the errors are a result of an incorrect makefile and not a result of errors in my c files. This is the first makefile that I've ever written so I might just be doing it completely incorrectly. Either way, any suggestions on how to get rid of these errors?

    Read the article

  • [UNIX] Sort lines of massive file by number of words on line (ideally in parallel)

    - by conradlee
    I am working on a community detection algorithm for analyzing social network data from Facebook. The first task, detecting all cliques in the graph, can be done efficiently in parallel, and leaves me with an output like this: 17118 17136 17392 17064 17093 17376 17118 17136 17356 17318 12345 17118 17136 17356 17283 17007 17059 17116 Each of these lines represents a unique clique (a collection of node ids), and I want to sort these lines in descending order by the number of ids per line. In the case of the example above, here's what the output should look like: 17118 17136 17356 17318 12345 17118 17136 17356 17283 17118 17136 17392 17064 17093 17376 17007 17059 17116 (Ties---i.e., lines with the same number of ids---can be sorted arbitrarily.) What is the most efficient way of sorting these lines. Keep the following points in mind: The file I want to sort could be larger than the physical memory of the machine Most of the machines that I'm running this on have several processors, so a parallel solution would be ideal An ideal solution would just be a shell script (probably using sort), but I'm open to simple solutions in python or perl (or any language, as long as it makes the task simple) This task is in some sense very easy---I'm not just looking for any old solution, but rather for a simple and above all efficient solution

    Read the article

  • for ps aux what are Ss Sl Ssl proccess types UNIX

    - by JiminyCricket
    when doing a "ps aux" command I get some process listed as Ss, Ssl and Sl what do these mean? root 24653 0.0 0.0 2256 8 ? Ss Apr12 0:00 /bin/bash -c /usr/bin/python /var/python/report_watchman.py root 24654 0.0 0.0 74412 88 ? Sl Apr12 0:01 /usr/bin/python /var/python/report_watchman.py root 21976 0.0 0.0 2256 8 ? Ss Apr14 0:00 /bin/bash -c /usr/bin/python /var/python/report_watchman.py root 21977 0.0 0.0 73628 88 ? Sl Apr14 0:01 /usr/bin/python /var/python/report_watchman.py

    Read the article

  • Hard link and Symbolic links in Unix

    - by darkie15
    Hi All, I just wanted to clarify if a hard/symbolic link is actually a file that is created ?? I ran the command: ln source hardlink ln -s source softlink -- The ls command shows this 2 links as a file. So my query is, does ln / ln -s actually create a file? Regards, Shyam

    Read the article

  • Unix Piping using Fork and Dup

    - by Jacob
    Lets say within my program I want to execute two child processes, one to to execute a "ls -al" command and then pipe that into "wc" command and display the output on the terminal. How can I do this using pipe file descriptors so far the code I have written: An example would be greatly helpful int main(int argc, char *argv[]) { int pipefd[2] pipe(pipefd2); if ((fork()) == 0) { dup2(pipefd2[1],STDOUT_FILENO); close(pipefd2[0]); close(pipefd2[1]); execl("ls", "ls","-al", NULL); exit(EXIT_FAILURE); } if ((fork()) == 0){ dup2(pipefd2[0],STDIN_FILENO); close(pipefd2[0]); close(pipefd2[1]); execl("/usr/bin/wc","wc",NULL); exit(EXIT_FAILURE); } close(pipefd[0]); close(pipefd[1]); close(pipefd2[0]); close(pipefd2[1]); }

    Read the article

  • How does one make sure or even guarantee server time are sync correctly between dozens of servers across multiple datacenter on different location?

    - by forestclown
    Currently our web applications contain a logic to check if the data sent to the web server is expired or not by comparing the timestamp of the data with the date/time of the server. Everything goes will, until some dude from data center accidentally modify one of the web server date/time and causes some disruptions in our web services. My managers are of course not happy with this, and said we shouldn't use timestamp to check expiry in the first place...anyway.... Network Time Protocol is implemented, because of data centers are spread across different continents so we have one NTP server in each data center. The servers within the data center will have cron jobs to check against the time with their NTP server from the same data center. If time is out of sync it will auto update the server date/time. But then with our managers not happy with it, and think it could still easily causes the same problem. e.g. what if someone accidentally modify the NTP date/time? what if all the NTP servers are out of sync with each other? which NTP servers we can really trust? and blah blah.. So my questions are: What are the current practice to sync date/time between servers across multiple data centers or locations? How does one manages time stamp between web apps? e.g. Server A send data (contain timestamp of Server A) to Server B (compare timestamp between Server B and the timestamp from the data to see if it has expired or not. This is to avoid HTTP replay) Should we really not use timestamp check? Thanks & Best Regards

    Read the article

  • Cleaning hanging IPCS in UNIX

    - by Sachin Chourasiya
    I knew that IPCRM is used to clean hanging IPCS and semaphores for a particumar user by passing the segment id or the semaphore id in either -m or -s option. WE NEED TO PASS INDIVIDUAL SEGMENT ID/ SEMAPHORE ID IN -m OPTION. Is there any way to clean ipcs that belongs to a particular user in just one move. I think shell script could be the way but not sure. Please help

    Read the article

  • shell script passing arguments

    - by arav
    From the wrapper shell scripts i am calling the Java program. I want the Unix shell script to pass all the arguments to java program except the EMAIL argument. HOW Can i remove the EMAIL argument and pass the rest of the arguments to the java program. EMAIL argument can come at any position. valArgs() { until [ $# -eq 0 ]; do case $1 in -EMAIL) MAILFLAG=Y shift break ;; esac done } main() { valArgs "$@" $JAVA_HOME/bin/java -d64 -jar WEB-INF/lib/test.jar "$@"

    Read the article

  • Pipeline For Downloading and Processing Files In Unix/Linux Environment With Perl

    - by neversaint
    I have a list of files URLS where I want to download them: http://somedomain.com/foo1.gz http://somedomain.com/foo2.gz http://somedomain.com/foo3.gz What I want to do is the following for each file: Download foo1,2.. in parallel with wget and nohup. Every time it complete download process them with myscript.sh What I have is this: #! /usr/bin/perl @files = glob("foo*.gz"); foreach $file (@files) { my $downurls = "http://somedomain.com/".$file; system("nohup wget $file &"); system("./myscript.sh $file >> output.txt"); } The problem is that I can't tell the above pipeline when does the file finish downloading. So now it myscript.sh doesn't get executed properly. What's the right way to achieve this?

    Read the article

  • Identifying and removing null characters in UNIX

    - by fahdshariff
    I have a text file containing unwanted null characters. When I try to view it in I see ^@ symbols, interleaved in normal text. How can I: a) Identify which lines in the file contains null characters? I have tried grepping for \0 and \x0, but this did not work. b) Remove the null characters? Running strings on the file cleaned it up, but I'm just wondering if this is the best way? Thanks

    Read the article

  • special character in UNIX

    - by Happy Mittal
    I want to add backspace character literally in my file named junk. So I did following $ ed a my name is happy\b (here b means I typed backspace so \ gets disapperaed and cursor sits sfter y) . w junk q But when I do $ od -cb junk it doesn't show backspace.

    Read the article

  • shell script passing subset of arguments

    - by arav
    From the wrapper shell scripts i am calling the Java program. I want the Unix shell script to pass all the arguments to java program except the EMAIL argument. HOW Can i remove the EMAIL argument and pass the rest of the arguments to the java program. EMAIL argument can come at any position. valArgs() { until [ $# -eq 0 ]; do case $1 in -EMAIL) MAILFLAG=Y shift break ;; esac done } main() { valArgs "$@" $JAVA_HOME/bin/java -d64 -jar WEB-INF/lib/test.jar "$@"

    Read the article

  • Ubuntu Equivalent of Unix Command cp -n

    - by Ted Karmel
    A software I need to install on my Ubuntu Hardy has a MAKE file which includes the command cp -n. However, I get an error stating the -n is an invalid option. The command will work on a Mac terminal but I need it to work on Ubuntu. Does anyone know the equivalent command for Ubuntu? Thanks.

    Read the article

  • How to send a Timestamp field to Oracle stored proc. from Java despite the DB config?

    - by Alfabravo
    I'm making a request from a java webapp to an Oracle' stored procedure which happens to have a Timestamp IN parameter. In the testing environment, it works sending: SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MMM-yyyy hh:mm:ss a"); input.setTimestampField(dateFormat.format(new Date())); But in the production environment, it raises an exception ORA-01830: date format picture ends before converting entire input string. I know the testing environment should be a replica of the production site, but it is not in my hands to set them properly. And I need to send the Timestamp field despite the way they setup the database. Any ideas? Thanks in advance.

    Read the article

  • Unix Interview Question [closed]

    - by Rachel
    I am giving some interviews right now and recently I was asked this questions in Interview and I was not sure of the answer, in your opinion are this kind of questions worthwhile for Interview process and if yes than how would you go about approaching this kind of questions. How to get number of files in directory without using wc ? How to get all files in descending order on size ? What is the significance of ? in file searching ? Would appreciate if you can provide answers for this questions so that I could learn something about them as I am not sure for this questions.

    Read the article

  • Passing multiple arguments to a UNIX shell script

    - by Waffles
    I have the following (bash) shell script, that I would ideally use to kill multiple processes by name. #!/bin/bash kill `ps -A | grep $* | awk '{ print $1 }'` However, while this script works is one argument is passed: end chrome (the name of the script is end) it does not work if more than one argument is passed: $end chrome firefox grep: firefox: No such file or directory What is going on here? I thought the $* passes multiple arguments to the shell script in sequence. I'm not mistyping anything in my input - and I the programs I want to kill (chrome and firefox) are open. Any help is appreciated.

    Read the article

  • running a program in Unix vs in Windows

    - by Hristo
    I'm compiling a simple program written in C and I'm using Eclipse as an IDE, both in Windows 7 and on my MacBook Pro. Very simple program my friend wrote and asked me to help him with: int a = 0; char b[2]; printf("Input first class info:\n"); printf("Credit Hours: \n"); scanf("%d", &a); printf("Letter Grade: "); scanf("%s", b); So when I run this on my mac, each line prints and when I encounter the scanf(), I can input and continue as expected. In Windows, I have to input everything and then it will print all the lines. I'm not sure why this is happening... what is the difference b/w Windows and Mac here? Mac: Input first class info: Credit Hours: 4 Letter Grade: B+ Windows: 4 B+ Input first class info: Credit Hours: Letter Grade: Thanks, Hristo

    Read the article

  • strange behaviour of grep in UNIX

    - by Happy Mittal
    When I type a command $ grep \\h junk then shell should interpret \\h as \h as two pairs of \ become \ each, and grep in turn, should interpret \h as \h as \ becomes \, so grep should search for a pattern \h in junk, which it is doing successfully. But it's not working for \\$. Please explain why ?

    Read the article

  • UNIX sort: Sorting something from the clipboard

    - by Iker Jimenez
    The other day I saw a colleague of mine using sort to sort a number of lines he copied from a text file. I've been trying to reproduce it myself and I cannot seem to find how. The requirements are as follow: Use sort from command line, plus whatever else you need to add to configure input Paste the text to be sorted from the clipboard Get the sorted result in the console

    Read the article

< Previous Page | 11 12 13 14 15 16 17 18 19 20 21 22  | Next Page >