Bash script - stripping away characters that can't be used in filenames
I want to create a temp file which is named based on a search string. The search string may contain spaces or characters that aren't supposed to be used in filenames so I want to strip those out.
My thought was to use 'tr' with [:alnum:] but the result is the opposite of what I want:
Hi there, if i have some strings ie
test_324423
test_242332
test_767667
but I only want the number part (the bolded bit) how do I strip the leftmost 5 characters from the output so that i will have just
324423
242332
767667
any help would be greatly appreciated
Gary (5 Replies)
I am trying to strip out certain characters from a string on both (left & right) sides. For example, line=see@hear|touch, i only want to echo the "hear" part. Well i have tried this approach:
line=see@hear|touch
templine=${line#*@} #removed "see@"
echo ${templine%%\|*} #removed... (4 Replies)
Hi all,
Am creating files and doing copy,compare and deletion.
As i do not want to mention the filepath everywhere, i store the filepaths in variables.
FILENAME="/home/test/create/Myfile.txt"
WR_PATH="/home/test/wrie/writefile.txt"
RD_PATH="/home/test/myread/readfile.txt"
echo "This is my... (2 Replies)
I'm trying to search all .odt files in a directory for a string in the text of the file.
I've found a bash script that works, except that it can't handle whitespace in the filenames.
#!/bin/bash
if ; then
echo "Usage: searchodt searchterm"
exit 1
fi
for file in $(ls *.odt); do
... (4 Replies)
I'm using a shell script to get user input with this command:
read UserInput
I would then like to take the "UserInput" variable and strip out all of the following characters, regardless of where they appear in the variable or how many occurrences there are:
\/":|<>+=;,?*@
I'm not sure... (5 Replies)
Dear experts,
my problem is pretty tricky.
I want to change a file (see attached input.txt), according to another file (help.txt). The output that is desired is in output.txt. The example is attached.
Note that
-dashes should not be treated specially, they are considered normal characters,... (2 Replies)
I have a group of files in different directories with characters such as " ? : in the file names. How do I find these files and remove these characters on mass?
Thanks (19 Replies)
hello,
I'm trying to figure out which tool is best for recursively renaming and files or folders using the characters \/*?”<>| in their name. I've tried many examples that use Bash, Python and Perl, but I'm not much of a programmer I seem to have hit a roadblock.
Does anyone have any... (15 Replies)
I wrote myself a small little shell script to clean up a file I have issues with. In particular, I am stripping down a fully qualified host/domain name to just the hostname itself. The script works, but from a performance standpoint, it's not very fast and I will be working with large data sets.
... (4 Replies)
Discussion started by: dagamier
4 Replies
LEARN ABOUT REDHAT
iswalnum
ISWALNUM(3) Linux Programmer's Manual ISWALNUM(3)NAME
iswalnum - test for alphanumeric wide character
SYNOPSIS
#include <wctype.h>
int iswalnum(wint_t wc);
DESCRIPTION
The iswalnum function is the wide-character equivalent of the isalnum function. It tests whether wc is a wide character belonging to the
wide character class "alnum".
The wide character class "alnum" is a subclass of the wide character class "graph", and therefore also a subclass of the wide character
class "print".
Being a subclass of the wide character class "print", the wide character class "alnum" is disjoint from the wide character class "cntrl".
Being a subclass of the wide character class "graph", the wide character class "alnum" is disjoint from the wide character class "space"
and its subclass "blank".
The wide character class "alnum" is disjoint from the wide character class "punct".
The wide character class "alnum" is the union of the wide character classes "alpha" and "digit". As such, it also contains the wide charac-
ter class "xdigit".
The wide character class "alnum" always contains at least the letters 'A' to 'Z', 'a' to 'z' and the digits '0' to '9'.
RETURN VALUE
The iswalnum function returns non-zero if wc is a wide character belonging to the wide character class "alnum". Otherwise it returns zero.
CONFORMING TO
ISO/ANSI C, UNIX98
SEE ALSO isalnum(3), iswctype(3)NOTES
The behaviour of iswalnum depends on the LC_CTYPE category of the current locale.
GNU 1999-07-25 ISWALNUM(3)