Help with a question i have attempted to figure out


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Help with a question i have attempted to figure out
# 1  
Old 03-05-2007
Help with a question i have attempted to figure out

Thought i should start this has a new thread.

i am stuck on the following question, but after learning more unix, i have written an answer to it. Can anyone check to see if it is correct and what improvements need to be made?

Question:

Write a pipeline that updates the content of a file (a file of your choice) by replacing all matches of the word ‘and' with the symbol ‘&' and by replacing the end of each line with the user login name. If the command completes successfully it should print ‘YES', otherwise it should print ‘NO'.

Answer:

cat text.txt | sed -e s/and/$USER/g -e s/$/”&”/g | cat -> text.txt
&& echo yes || echo no

thanks
 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Fatal division by zero attempted

Hello. I'm writing an awk script that looks at a .csv file and calculates the weighted grade based on the scores and categories in the file. I keep getting a fatal division by zero attempted error and I know what it means but I've been looking over the code for awhile and am not sure what is... (4 Replies)
Discussion started by: Eric7giants
4 Replies

2. Shell Programming and Scripting

Division by zero attempted error during linear conversion of values between 0.25 to 1

I want to implement the below formula with awk oneliner new_value = ((old_value - old_min) / (old_max - old_min) ) * (new_max - new_min) + new_min I want to pass the value of old_min and old_min as variable. Here is what I did for this old_min=$(awk 'BEGIN{a=100000000000}{if ($10<0+a) a=$10}... (2 Replies)
Discussion started by: sammy777888
2 Replies

3. Shell Programming and Scripting

Help with change significant figure to normal figure command

Hi, Below is my input file: Long list of significant figure 1.757E-4 7.51E-3 5.634E-5 . . . Desired output file: 0.0001757 0.00751 0.00005634 . . . (10 Replies)
Discussion started by: perl_beginner
10 Replies

4. Shell Programming and Scripting

awk fatal:division by zero attempted bypass with a condtion

Hi Friends, My input chr1 100 200 1234E-02 0.01 0.05 10 chr1 100 200 14E-11 0.11 0.50 1 chr1 100 200 134E-22 0.00 0.65 111 My command awk '{print $1"\t"$2"\t"$3"\t"$4"\t"$5"\t"$6"\t"$13}' input | awk '{v=($5/$6); print $0"\t"v}' OFS="\t" | awk '{$8=(log($8)/log(2)); print $0}'... (4 Replies)
Discussion started by: jacobs.smith
4 Replies

5. Shell Programming and Scripting

Awk: cmd. line:1: fatal: division by zero attempted

when i try the snippet in the console its working fine: ps awwwux | grep php-fpm | grep -v grep | grep -v master | awk '{total_mem = $6 * 1024 + total_mem; total_proc++} END{printf("%d\n", total_mem / total_proc)}' output: but when i try the bash script: #!/bin/sh # -*- sh -*- #... (3 Replies)
Discussion started by: danieloooo
3 Replies

6. UNIX for Dummies Questions & Answers

Can't figure this one out --

I'm putting together a shell script while I'm learning UNIX -- just for myself. It's a little script that simply takes some vendor names and writes them to a file. So far I'm at the stage where the user enters the name of the file and places it in a folder called vendorlists: * ) touch... (5 Replies)
Discussion started by: Straitsfan
5 Replies

7. Shell Programming and Scripting

awk error message: division by zero attempted

Hi, I'm executing unixbench tool v4.1 on an embedded system and I'm getting these error messages: Execl Throughput 1 2 3awk: /unixbench/unixbench-4.1.0/pgms/loops.awk:38: (FILENAME=- FNR=4) fatal: division by zero attempted Pipe Throughput 1 2 3 4 5 6 7 8 9 10awk:... (3 Replies)
Discussion started by: rogelio
3 Replies

8. Shell Programming and Scripting

error "awk: (FILENAME=- FNR=23) fatal: division by zero attempted"

Hi , I have file : after i run this command : there are error can we print blank line if output error ?? thanks.. ^^ (4 Replies)
Discussion started by: justbow
4 Replies

9. UNIX for Dummies Questions & Answers

i can not figure this out

I am having problems scripting in UNIX. I am currently attending school and for the first time I am being introduced to scripting. My problem is I am supposed to enhance the spell_check by adding a third optional argument. The third argument is to specify a list of words to be added to the... (1 Reply)
Discussion started by: steph
1 Replies
Login or Register to Ask a Question
CLASP(1)						      General Commands Manual							  CLASP(1)

NAME
clasp - a conflict-driven nogood learning answer set solver SYNOPSIS
clasp [number][options] DESCRIPTION
This manual page documents briefly the clasp command. clasp is an answer set solver for (extended) normal logic programs. It combines the high-level modeling capacities of answer set program- ming (ASP) with state-of-the-art techniques from the area of Boolean constraint solving. The primary clasp algorithm relies on conflict- driven nogood learning, a technique that proved very successful for satisfiability checking (SAT). Unlike other learning ASP solvers, clasp does not rely on legacy software, such as a SAT solver or any other existing ASP solver. Rather, clasp has been genuinely developed for answer set solving based on conflict-driven nogood learning. clasp can be applied as an ASP solver (on LPARSE output format), as a SAT solver (on simplified DIMACS/CNF format), or as a PB solver (on OPB format). OPTIONS
These programs follow the usual GNU command line syntax, with long options starting with two dashes (`-'). A summary of options is included below. For a complete description, see <http://www.cs.uni-potsdam.de/clasp/>. -h, --help Show summary of options. -v, --version Show version of program. SEE ALSO
gringo(1). AUTHOR
clasp was written by Benjamin Kaufmann <kaufmann@cs.uni-potsdam.de>. This manual page was written by Thomas Krennwallner <tkren@kr.tuwien.ac.at>, for the Debian project (and may be used by others). March 4, 2010 CLASP(1)