06-26-2008
how to separate numbers and words from a file using shell scripts
Hi,
How to separate numbers and words(with full alphabets) in a particular file and store it in two different files.
Please help me out for this.Using shell scripting.
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Hi,
I want to list all the words in my file on a separate line.
I am using the bourne(sh)/bourne again shell(bash).
Thanks,
theA (2 Replies)
Discussion started by: Astudent
2 Replies
2. Shell Programming and Scripting
I am trying to parse hundreds of shell scripts to determine how they related to each other. Ideally for every script, I would get an output of:
What other scripts it calls
What files it reads
Environment variables it accesses
Any ideas on how to do this?
TIA! (2 Replies)
Discussion started by: bliss
2 Replies
3. Shell Programming and Scripting
hi,
I am a begginer in unix and i want to know how to open a file and read it and separate the numbers & words and storing it in separate files, Using shell scripting.
Please help me out for this.
Regards
S.Kamakshi (2 Replies)
Discussion started by: kamakshi s
2 Replies
4. Shell Programming and Scripting
Hello friends,
Im trying to separate a number from a log, but it seems i need help here
awk '/stimated/ {print $5}' mylog.txt
gives (1515.45MB).
i need pure number part to use in a comparision loop so i want to separate the number part (but only 1515 not 1515.45 )
awk '/stimated/... (6 Replies)
Discussion started by: EAGL€
6 Replies
5. Shell Programming and Scripting
I have this command in a shl (UNIX) to find the lates file that start with EMT in a directory
file=$(ls -tr $EMT*.dat | tail -1) # Select the latest file
It finds:
EMT345.dat
then I have to be able to separate EMT AND the numbers 345 and stored 345 in a variable and incremented, so my new... (7 Replies)
Discussion started by: rechever
7 Replies
6. Shell Programming and Scripting
Hi all
i have a data of this form
10.12.4.22:138
10.12.2.50:137
10.20.2.24:1027
10.12.2.44:138
10.12.2.44:137
10.0.4.38:58871
10.13.3.19:138
i need to separate the number out which is at the last and after ':'
Please help me out
Thanx in advance (5 Replies)
Discussion started by: vaibhavkorde
5 Replies
7. Shell Programming and Scripting
Hi All,
I need to execute a SQL via shell script and i am connecting to Oracle DB by this way $USERNAME1/$PASSWORD1@$STRING1 and i need to get username, password and string from someother file stored in the Unix Directory. $Username, $Password and $String is stored in File A in Path A and i want... (3 Replies)
Discussion started by: sathish.tn
3 Replies
8. Shell Programming and Scripting
Hi there,
Firstly, I have no experience with shell scripts so would really appreciate some help.
I have the following shell script that is causing some problems:
moveit()
{
&& set -x
if
then
DOUBLE_DELIVERY=$(grep... (6 Replies)
Discussion started by: thebeno
6 Replies
9. Shell Programming and Scripting
I would like to separate number by space so that
121231212
222111212
would be
1 2 1 2 3 1 2 1 2
2 2 2 1 1 1 2 1 2
Thanks! (2 Replies)
Discussion started by: johnkim0806
2 Replies
10. Shell Programming and Scripting
Hello,
I want to grep a log ("server.log") for words in a separate file ("white-list.txt") and generate a separate log file containing each line that uses a word from the "white-list.txt" file.
Putting that in bullet points:
Search through "server.log" for lines that contain any word... (15 Replies)
Discussion started by: nbsparks
15 Replies
LEARN ABOUT MOJAVE
wordfree
WORDEXP(3) BSD Library Functions Manual WORDEXP(3)
NAME
wordexp -- perform shell-style word expansions
SYNOPSIS
#include <wordexp.h>
int
wordexp(const char * restrict words, wordexp_t * restrict we, int flags);
void
wordfree(wordexp_t *we);
DESCRIPTION
The wordexp() function performs shell-style word expansion on words and places the list of words into the we_wordv member of we, and the num-
ber of words into we_wordc.
The flags argument is the bitwise inclusive OR of any of the following constants:
WRDE_APPEND Append the words to those generated by a previous call to wordexp().
WRDE_DOOFFS As many NULL pointers as are specified by the we_offs member of we are added to the front of we_wordv.
WRDE_NOCMD Disallow command substitution in words. See the note in BUGS before using this.
WRDE_REUSE The we argument was passed to a previous successful call to wordexp() but has not been passed to wordfree(). The implementa-
tion may reuse the space allocated to it.
WRDE_SHOWERR Do not redirect shell error messages to /dev/null.
WRDE_UNDEF Report error on an attempt to expand an undefined shell variable.
The wordexp_t structure is defined in <wordexp.h> as:
typedef struct {
size_t we_wordc; /* count of words matched */
char **we_wordv; /* pointer to list of words */
size_t we_offs; /* slots to reserve in we_wordv */
} wordexp_t;
The wordfree() function frees the memory allocated by wordexp().
IMPLEMENTATION NOTES
The wordexp() function is implemented as a wrapper around the undocumented wordexp shell built-in command.
RETURN VALUES
The wordexp() function returns zero if successful, otherwise it returns one of the following error codes:
WRDE_BADCHAR The words argument contains one of the following unquoted characters: <newline>, '|', '&', ';', '<', '>', '(', ')', '{', '}'.
WRDE_BADVAL An attempt was made to expand an undefined shell variable and WRDE_UNDEF is set in flags.
WRDE_CMDSUB An attempt was made to use command substitution and WRDE_NOCMD is set in flags.
WRDE_NOSPACE Not enough memory to store the result.
WRDE_SYNTAX Shell syntax error in words.
The wordfree() function returns no value.
ENVIRONMENT
IFS Field separator.
EXAMPLES
Invoke the editor on all .c files in the current directory and /etc/motd (error checking omitted):
wordexp_t we;
wordexp("${EDITOR:-vi} *.c /etc/motd", &we, 0);
execvp(we.we_wordv[0], we.we_wordv);
DIAGNOSTICS
Diagnostic messages from the shell are written to the standard error output if WRDE_SHOWERR is set in flags.
SEE ALSO
sh(1), fnmatch(3), glob(3), popen(3), system(3)
STANDARDS
The wordexp() and wordfree() functions conform to IEEE Std 1003.1-2001 (``POSIX.1'').
BUGS
Do not pass untrusted user data to wordexp(), regardless of whether the WRDE_NOCMD flag is set. The wordexp() function attempts to detect
input that would cause commands to be executed before passing it to the shell but it does not use the same parser so it may be fooled.
The current wordexp() implementation does not recognize multibyte characters, since the shell (which it invokes to perform expansions) does
not.
BSD
July 29, 2004 BSD