Ubuntu :: Correct Syntax For Regex In Shell Script?
Nov 5, 2010
This command works to find files that have been updated in past 90 minutes:
Code:
find ( ! -regex '.*/..*' ) -type f -mmin -90
What changes need to be made to set this as an alias in, say, .cshrc file? I'm getting:
[code]....
View 5 Replies
ADVERTISEMENT
Oct 9, 2010
was trying to figure out how to use
Code:
lftp mirror -v ----remove-source-files sftp://user@ftp.site.com
I keep getting "unknown option --remove-source-files. Could anyone help?
View 1 Replies
View Related
Jun 1, 2009
If I want to share a directory called /home/me, would I go to my /etc/exports file and share /home/me/* or would I share /home/me ? I am unsure of how to type this into the file.
View 2 Replies
View Related
Mar 30, 2010
I use F12 and I need help with correct syntax to specify range of IP address in hosts.allow or hosts.deny or in /etc/exports file eg. 192.168.1.100 to 192.168.1.255.
View 13 Replies
View Related
May 25, 2010
I need to create the following cron jobs:
job #1: runs Mon, Tue, Wed, Thu, Fri, Sun at 9PM every month except for 15th
job#2: runs on 15th of each month at 9PM
job #3: runs every Saturday at 6PM every month
What is the correct syntax for this kind of scheduled cron jobs?
View 7 Replies
View Related
May 28, 2011
I am writing a simple shell script where it checks the condition using if condition.
Code:
if [ $name == "JOHN" ] then admin='YES'; fi
if I use like this I am getting below error
[code]....
View 1 Replies
View Related
Jan 4, 2011
Some may recall I recently gave up on bash, rather than give up my programming style.Surely I will have reason to return but that's another story. My little issue now:I am debugging a new [Korn] shell script. I have a function that performs a specialized match on a string and I see that I am able to call that function with no problem, with both of it parameters. The function does not do any print or echo command - it uses "return" for a TRUE (0) of FALSE (1), as is the shell exit code convention. Thus, I have the following test:
Code:
if [[ match_except_release ${PATH_DIR[$LC]} bin ]]
then
[code]....
View 2 Replies
View Related
Apr 25, 2011
I know it's possible to change the $ user@hostname colors, but is it possible to color different things? Could I make all numbers/integers a certain color. Or set certain keywords to be bold?
View 1 Replies
View Related
Apr 28, 2011
I'm trying to be able to Open a text editor without needing an existing file.This is my code:
case $ans in
"Show Today") echo "$(date)";;
"Show Calendar") cal;;
[code]...
View 14 Replies
View Related
Apr 5, 2011
I am trying to modify a script for research purposes and am having difficulty here as I have little prior experience with C-shell scripting.
The script looks as follows (it includes tcl commands like runFEP that you can ignore)
#!/bin/bash
for ((old=1, new=2; old<=4; old++,new++))
a1=${old}%50
a2=${new}%50
do
cat > input${new}.conf <<EOF
${a1}
code....
My question: I keep getting a syntax error when defining my two variables a1 and a2. I essentially need these variables to be
a1 = value of variable old divided by 50
a2 = value of variable new divided by 50
View 1 Replies
View Related
May 6, 2011
Im a bit stuck with a simple script that im practicing with... im trying to get my head around some simple scripting. Basically i want to write a script that will work as below: It will ask the user to enter their userid. If its correct it will say 'Correct' If its the wrong id (But the ID exists in /etc/passwd) then it will say 'incorrect' If its not a valid userid it will say 'doesnt exist'. What i have so far is:
[Code]...
# If the user enters their own userid they will get a comment saying 'correct' $LOGNAME) echo "Correct";;
# If they enter another users ID (That exists in the /etc/passwd), then they get a message to say 'incorrect userid used'. Im not sure what i need to do here to get it to check the /etc/passwd to see if the input exists in there.... im guessing some kind of simple 'if' statement to say ---- "if 'input' exists in /etc/passwd then echo "incorrect userid used"
# If its entered incorrectly and not a valid ID then they will get this comment. Again, im guessing this part would be similar to te above option..... *) echo "not a valid ID";;
Ive managed to work out how the basic Case staements work, but to add a conditional statement based on the input, i just cant figure out. I have tried looking on google, and found some help but it doesnt really explain how i check the input against the /etc/passwd.
View 17 Replies
View Related
Jul 9, 2010
I was trying to run small shell script, but could not run. I got the error like in subject.
This is exact way i was trying to do.
View 6 Replies
View Related
Jan 21, 2011
I want to rename some files in one directory and found the command 'rename' most appropriate.
Changing the file extension is easy since there are lot of examples for this.
But now I want to rename my files like this:
'somePrefix_blablabla.ext' --> '0_blablabla.ext'
'somePrefix_blablablablabla.ext' --> '0_blablablablabla.ext'
I DON'T want an incrementation, just the leading prefix '0_'
correct perl expression syntax for this?
View 2 Replies
View Related
Mar 7, 2011
When ever i open vim, i get the error that the following error: E484: Can't open file/abcd/configFiles/vim/syntax/syntax.vim There was a .vimrc file in my home folder that i have removed.
Still i keep getting the same error. Presently in my home folder there is no .gvimrc or .vimrc file.
But still i keep getting the same error. I am not too sure where this file is mentioned.
Background info: The SHELL has been changed from tcsh to bash Earlier i had created a .vimrc file in tcsh, i have removed the .vimrc in bash SHELL.
View 1 Replies
View Related
Apr 20, 2011
I am a Novell (now defunct) CNE tring to learn Linux and am having a lot of trouble finding out where the WB 6-6 is wrong in the syntax for adding local4... the the syslog-ng config file. In the instructions there are discrepancies between commas and simi-comma, they are both in the statements in no particular order. there is no pattern to them. Here is what the book shows:
filter f_local4debug { level(debug) and facility(local4); };
When I try to input this in the Gnome terminal window to try and find out where it goes wrong I get the following: -bash: syntax error near unexpected token "(" If I can get the correct syntax I belive I can use the info to get past the rest of this portion of the lesson. I am desperate to learn Linux as the only jobs out there for a Novell CNE are migrations to MS, which really sucks, since MS really really sucks.
View 1 Replies
View Related
May 17, 2010
I'm trying to craft a tricky regex using Sed. I'm trying to clean up some code which has bazillions of lines over 80 characters in length, mainly because of these end-of-line comments. I want to change them to a nicer format. I've put the code on Pastebin because the formatting is better: [URL]. Bear in mind those are tabs, not spaces.
View 1 Replies
View Related
Apr 22, 2011
This makes me feel like a total n00b but I'm trying to figure out how to replace an XML close tag (such as </pagenum> ) with the same XML close tag followed by yet another close tag. (I want every occurrence of '</pagenum>' to be replaced with '</pagenum></p>').
I've tried using something like this:
Code:
sed 's/</pagenum>/</pagenum></p>/' old.xml new.xml
What am I missing? Please forgive me. I'm diving head first into RegEx.
View 5 Replies
View Related
Oct 9, 2010
I know it's against the unix way and all that but I need a regex cd for a script to automatically move up an NTFS tree.
View 1 Replies
View Related
Feb 4, 2011
At my work i have a legacy web system that tells the id of documents based on some given variables. this information can be used in another system to retrieve the needed file.
I am trying to automate this, and have managed to feed the variables and download the correct page using wget. The result is a result.php page with a lot of embedded info.
The information i am looking for is enclosed in single quotes on a line like this:
The information i want is the 1234 part.
I thought i could do like this from bash:
But I always get an empty string back... any idea what i am doing wrong?
View 1 Replies
View Related
Jun 20, 2011
My friend lost her dissertation and she had only a pdf copy of it. I am trying to convert the pdf into an odt format. After copy-pasting the content into an odt, i need to replace all paragraph breaks which are not following a dot with a space. For which i thought of using the regular expression feature of Libre Office. I've not succeeded so far.
I tried: to replace [:alpha:]$ or [a-z]$ or [a-z]>$ with space, but none of them worked. Finding [a-z] seems to work, finding [a-z]> too. So did finding $ (end of paragraph) but if i combine any regex with $ then it doesn't find anything.
View 7 Replies
View Related
Apr 2, 2010
I have a data file with the following format 0 i j # # # # with other random lines of text to be filtered out.The following script works when there aren't many #s, but it shuffles long lists of data.
/^0/ {
split($0,token)
printf("%s %s ", $2, $3)
[code]...
View 4 Replies
View Related
Jul 18, 2011
So I just recently downloaded Regex-PreSuf. I believe it downloaded correctly, and also install correctly (did the following):
> downloaded it
> gzipped
> tar'ed
> perl Makefile.PL
> make
> make test
> make install
This is the file listing after the make install completed:
[Code]....
The output from the make, and make install gave the All OK, but there is no documentation with it that shows how to use it? Does anyone know what you have to do to use it? From what I read, it is used to enter a string and it gives you the regex that matches that string exactly? This is what I tried, from within the directory and its the output:
[Code]....
View 4 Replies
View Related
May 14, 2011
I need a regex expression to read IP address from lines like these for my perl script:
Code:
2011.05.13-14:54:58, test@xyz.com, 180.211.51.11, pop3
2011.05.13-14:57:26, test@xyz.com, 160.234.47.12, pop3
2011.05.13-14:57:54, www@abcd.com, 166.22.22.224, imap
2011.05.13-14:57:55, www@somedomain.com, 172.58.22.154, imap
2011.05.13-15:03:08, www@example.com, 190.22.120.44, pop3
View 6 Replies
View Related
Jul 12, 2010
Are there some good tutorials or reference materials on how do pattern matching and text manipulation in Linux?I have a few simple tasks I'd like taken care of...like formatting numbers in file names, stripping some text from directory names, etc
View 2 Replies
View Related
Dec 10, 2010
regex in grep? I need to match ANYTHING in the following with any character combination (something like * in findstr in C): grep "Delivery of nonspam" /var/log/mail.log | grep "to [URL]"
View 1 Replies
View Related
Mar 27, 2011
In a bash shell script, I want to do something like this:
Code:
if [[ $(ls -ld /some/dir/foo_* | wc -l) -gt 4 ]]; then
rm -rf first_match_of /some/dir/foo_*
[code]....
View 6 Replies
View Related
Apr 12, 2011
I'm wondering if it's POSIX + ASCII or something else is mixed in?
View 1 Replies
View Related
Jan 13, 2010
I am not a big skype user, but I was chatting with my sister, made a typo and habitually typed
tpyo
s/tpyo/typo/
to my surprise it actually changed the history. I am using the linux skype client 2.1.0.47-r1 and my sister is using 4.something on windows.
When she tried to do the same thing, it didn't work. Does anyone know if this is specific to the linux version?
View 1 Replies
View Related
Jan 13, 2011
In a bash-script, only the case if a regular expression does not match is relevant.herefore I used the exclamation mark !. But where to place it?
These two work fine, but are they equivalent?
Code: if ! [[ $abc =~ $pattern ]]; then or
Code: if [[ ! $abc =~ $pattern ]]; then Where is the ! placed more correct?
View 2 Replies
View Related
Jun 1, 2011
I'm just starting out with bash scripting (yesterday, really). I want to add a file to each user's home directory, pretty simple really, and send it out via our Apple Remote Desktop system to our Macs. Here is my script: Code: #!/bin/bash
for i in $(ls -d /Users/*)
doif [ -e $i/.tcshrc ]
thenecho "$i/.tcshrc exists!"elseecho "$i/.tcshrc does not exist"
[code]....
View 6 Replies
View Related