Back quote problem

 
Thread Tools Search this Thread
Homework and Emergencies Homework & Coursework Questions Back quote problem
# 1  
Old 11-12-2014
Back quote problem

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!

1. The problem statement, all variables and given/known data:
Print out problem with line follow:

Code:
echo There are '$cat $fname | wc -l' contacts in database

how do I replace single quote with a backquote from Vi or nano?

2. Relevant commands, code, scripts, algorithms:

Code:
#!/bin/bash

#export all output to fname

fname=names.dat

echo "Please Enter your contact name as follow:"

echo "Given name: "
read name

echo "Surname: "
read surname

echo "Street address"
read street

echo "City you live in"
read city

echo "States"
read states

echo "Zip code"
read zipcode

echo $name   $surname   $street   $city   $states   $zipcode >> $fname

{
 echo
 echo Here are the current contacts in the database:
 echo
 cat $fname

} | more

echo There are "$cat $fname | wc -l" contacts in database


3. The attempts at a solution (include all code and scripts):
Code:
There are  names.dat | wc -l contacts in database

My attempt to printout how many users in database

4. Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):
This does not relate to my school work.. Addition info that I learn from my own.

Note: Without school/professor/course information, you will be banned if you post here! You must complete the entire template (not just parts of it).

Last edited by scopiop; 11-12-2014 at 11:53 PM.. Reason: Add CODE tags.
# 2  
Old 11-12-2014
Since you are using bash rather than a pure Bourne shell, why not use:
Code:
$(cat $fname | wc -l)

or, much better,
Code:
wc -l < "$fname"

instead of:
Code:
`cat $fname | wc -l`

?

If you must use backquotes, on most US keyboards, the backquote (`) and tilde (~) characters are on the key to the left of the key with 1 (unshifted) and ! (shifted).
# 3  
Old 11-13-2014
Thank you.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Replacing all but the first and last double quote in a line with a single quote with awk

From: 1,2,3,4,5,This is a test 6,7,8,9,0,"This, is a test" 1,9,2,8,3,"This is a ""test""" 4,7,3,1,8,"""" To: 1,2,3,4,5,This is a test 6,7,8,9,0,"This; is a test" 1,9,2,8,3,"This is a ''test''" 4,7,3,1,8,"''"Is there an easy syntax I'm overlooking? There will always be an odd number... (5 Replies)
Discussion started by: Michael Stora
5 Replies

2. Homework & Coursework Questions

Problem with using using quote in awk script

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: i have the output of a csh script piped to an awk script. In the awk script i was trying to assign a variable... (3 Replies)
Discussion started by: ymc1g11
3 Replies

3. Shell Programming and Scripting

quote problem

Hi Everyone hwo are you i have one file "abc.txt" which contains record like this "1","2","3" "3","4","5" now i want to change above 2 to 5 so i write the code as awk ' BEGIN{FS=","} { if(NR==1) { print $1",5","$3 } else { print $0 } ' abc.txt but the outpute is "1",5,"3"... (5 Replies)
Discussion started by: aishsimplesweet
5 Replies

4. Shell Programming and Scripting

remsh problem with single quote (')

Hi All, Im executing the shell script remotely. here is one statement from that: remsh $rHost -l $rUser "java -jar $TARGET/toolkit/apps/bin/toolkit-stm.jar network -m -d1 /abmusr06/abm/users/dywrk01/$package/DYP_Execution/data/configuration/network_aus/network -u2... (1 Reply)
Discussion started by: AB10
1 Replies

5. Shell Programming and Scripting

replacing a quote in some lines with multiple quote fields

i want to replace mistaken quotes in line starting with tag 300 and relocate the quote in the correct position so the input is 223;25 224;20100428064823;1;0;0;0;0;0;0;0;8;1;3;9697;18744;;;;;;;;;;;; 300;X;Event:... (3 Replies)
Discussion started by: wradwan
3 Replies

6. Shell Programming and Scripting

Regex in grep to match all lines ending with a double quote (") OR a single quote (')

Hi, I've been trying to write a regex to use in egrep (in a shell script) that'll fetch the names of all the files that match a particular pattern. I expect to match the following line in a file: Name = "abc" The regex I'm using to match the same is: egrep -l '(^) *= *" ** *"$' /PATH_TO_SEARCH... (6 Replies)
Discussion started by: NanJ
6 Replies

7. Shell Programming and Scripting

single quote problem with rsync

Hi everybody, I'm a newbie and hope that someone help me in this problem. I have a filename in LINUX with single quote like this: abs@hosttest:~/ABS/BETY/cygdrive/C/DECLARANOT 1.1.4/02 - ROCK/052 - GUNSROSES> dir You* -rw-r--r-- 1 abs users 2365881 2008-08-25 09:16 You're Crazy.mp3 ... (9 Replies)
Discussion started by: mr_boysito
9 Replies

8. Shell Programming and Scripting

Capturing Data between first quote and next quote

I have input file like RDBMS FALIURE UTY8703 'USER_WORK.TEST' .HIghest return code '12' I want to parse data which comed between first quote till next quote USER_WORK.TEST can you please suggest how to do that (4 Replies)
Discussion started by: scorp_rahul23
4 Replies

9. Shell Programming and Scripting

Problem with double quote and string variable

Hello, i have a file output.txt which contains a single line with a list of files with quotes : "file1.ext" "file2.ext" "file3.ext" In a shell script, I want to retrieve the line and use it as a variable in a command like : zip archive.zip $LIST I cant get it work. When I physically type... (6 Replies)
Discussion started by: mattemp
6 Replies

10. UNIX for Dummies Questions & Answers

back up problem

Hi all I am facing some problem taking INCREMENTAL Back up of file systems...........Actually i have mounted the file system of one server in another server..as i don't have tape drive in both servers...............i am using HPUX(L class and C class)servers.. can any one help me ... (1 Reply)
Discussion started by: Prafulla
1 Replies
Login or Register to Ask a Question