But Im trying to call this command (sed -n "$linenum p" file1.txt) from a pipeline in C and I doesn't works ... And I think the error is the double quotes can i run the command something different.. sed -n $linenum p file1.txt (but this way doesn't work)
Hi, i've got the following:
a=`echo $b | grep '^.*/'`
i'm storing in the variable the value of the variable b only if it has a / somewhere.
It works, but i don't want to print the value. How do i give the value of b to the grep command without the echo?
thanks! (5 Replies)
I am performing a grep command and I need to know how to echo "NONE" or "0" to my file if grep does not find what i am looking for.
echo What i found >> My_File
grep "SOMETHING" >> My_File
I am sure this is easy, I am sort of new at this!
Thanks (2 Replies)
Hi,
I am cutting data from a fixed length test file and then writing out a new record using the echo command, the problem I have is how to stop multiple spaces from being written to the output file as a single space.
Example:
cat filea | while read line
do
field1=`echo $line | cut -c1-2`
... (6 Replies)
Hello,
well what I'm trying to do is to remove underscores from filenames and leaving empty spaces instead:
arturas@Universe:/windows/Center/training$ ls
big_file failas su shudu
arturas@Universe:/windows/Center/training$ a=big_file
arturas@Universe:/windows/Center/training$ mv $a `echo... (8 Replies)
Is there any way in a script to print out the commands being ran? In DOS script, there is the "@echo on" and "@echo off".
so I have a script like this:
#!/bin/ksh
echo "hello there. moving files."
<turn on echoing here>
cp thisfile.txt thatfile.txt
cp whatfile.prop whyfile.prop
<turn... (2 Replies)
My current line command is as follows:
echo -n "text: " ; grep "blah text" ../dir1/filename | wc -l
The output to the screen is as needed, but how do I print to a text file? (9 Replies)
Is there an environment issue that would not allow the following not store and pass the value into this field:
underScorePresent=`echo $USER | grep "_" | wc -l`
It is running on a new redhat 6.5 OS. The value $USER is set to cpac. It is a vendor code and they are saying it is environment... (1 Reply)
version info : Fedora 28 (Kernel version: 4.16.12-300)
shell : bash
Using echo command , if I redirect a text like "Chocolate" to a file , all the contents in the file are overwritten as shown below.
# cat /tmp/someTest
Hello world
One more Hello world
myLine3
# echo... (4 Replies)
Discussion started by: kraljic
4 Replies
LEARN ABOUT LINUX
error
ERROR(3) Linux Programmer's Manual ERROR(3)NAME
error, error_at_line, error_message_count, error_on_per_line, error_print_progname - glibc error reporting functions
SYNOPSIS
#include <error.h>
void error(int status, int errnum, const char *format, ...);
void error_at_line(int status, int errnum, const char *filename,
unsigned int linenum, const char *format, ...);
extern unsigned int error_message_count;
extern int error_one_per_line;
extern void (* error_print_progname) (void);
DESCRIPTION
error() is a general error-reporting function. It flushes stdout, and then outputs to stderr the program name, a colon and a space, the
message specified by the printf(3)-style format string format, and, if errnum is nonzero, a second colon and a space followed by the string
given by strerror(errnum). Any arguments required for format should follow format in the argument list. The output is terminated by a
newline character.
The program name printed by error() is the value of the global variable program_invocation_name(3). program_invocation_name initially has
the same value as main()'s argv[0]. The value of this variable can be modified to change the output of error().
If status has a nonzero value, then error() calls exit(3) to terminate the program using the given value as the exit status.
The error_at_line() function is exactly the same as error(), except for the addition of the arguments filename and linenum. The output
produced is as for error(), except that after the program name are written: a colon, the value of filename, a colon, and the value of
linenum. The preprocessor values __LINE__ and __FILE__ may be useful when calling error_at_line(), but other values can also be used. For
example, these arguments could refer to a location in an input file.
If the global variable error_one_per_line is set nonzero, a sequence of error_at_line() calls with the same value of filename and linenum
will result in only one message (the first) being output.
The global variable error_message_count counts the number of messages that have been output by error() and error_at_line().
If the global variable error_print_progname is assigned the address of a function (i.e., is not NULL), then that function is called instead
of prefixing the message with the program name and colon. The function should print a suitable string to stderr.
CONFORMING TO
These functions and variables are GNU extensions, and should not be used in programs intended to be portable.
SEE ALSO err(3), errno(3), exit(3), perror(3), program_invocation_name(3), strerror(3)COLOPHON
This page is part of release 3.27 of the Linux man-pages project. A description of the project, and information about reporting bugs, can
be found at http://www.kernel.org/doc/man-pages/.
GNU 2010-08-29 ERROR(3)