Tag Info

New answers tagged

1

From the tcsh manual: Variable substitution Unless enclosed in ' " ' or given the ':q' modifier the results of variable substitution may eventually be command and filename substituted. You have a variable that expands to something syntactically incorrect for filename substitution. You can prevent that substitution by typing echo "$prompt" or echo ...


4

Using vim, it's super simple: $ vim filename gg^guGZZ Opens the file, goes to the first line, first column. Lowers the case of all the characters until the bottom of the file. Saves and exits. It should handle just about anything you throw at it; it'll ignore numbers, it'll handle non ASCII.


6

I like dd for this, myself. <<\IN LC_ALL=C 2>/dev/null \ dd conv=lcase hi Jigar GANDHI jiga IN ...gets... hi jigar ghandi jiga The LC_ALL=C is to protect any multibytes in input - though any multibyte capitals will not be converted. The same is true for (GNU) tr - both apps are prone to input mangling in any non-C locale. iconv can be ...


4

You can also use Perl 5: perl -pe '$_=lc' temp The option -p tells perl to run the specified expression once for each line of input, printing the result, i.e. the final value of $_. -e indicates that the program will be the next argument, as opposed to a file containing the script. lc converts to lowercase. Without an argument, it will operate on $_. And ...


4

You need to capture the matched pattern and then use it in the replacement with a modifier: sed 's/\([A-Z]\)/\L\1/g' temp The \(...\) "captures" the enclosing matched text, the first capture goes to \1, the next to \2, etc. The numbering is according to opening brackets in case of nested captures. The \L converts the captured pattern to lower case, ...


14

If your input only contains ASCII characters, you could use tr like: tr A-Z a-z < input or (less easy to remember and type IMO, but not limited to ASCII latin letters): tr '[:upper:]' '[:lower:]' < input if you have to use sed: sed 's/.*/\L\1/g' < input (here assuming the GNU implementation).


1

You can list all currently active keybinds in tcsh with the bindkey command: % bindkey Standard key bindings "^@" -> set-mark-command "^A" -> beginning-of-line "^B" -> backward-char "^C" -> tty-sigintr ... etc ... In this output, ^[ is the escape character this is Esc followed by your key (eg. p). ...


0

For bash and some other shells, you can read the man page of readline which contains a list of possible key bindings for editing (by default the Emacs mode is used). Some of them also work for tcsh.


2

If you just store a string in $now, and add backticks when you invoke it, you get the current date: [~]% setenv now 'date +"%b_%d_%T"' [~]% echo $now date +"%b_%d_%T" [~]% echo `$now` "Dec_03_13:09:52" [~]% echo `$now` "Dec_03_13:09:54" This is effectively the same as doing: [~]% echo `date +"%b_%d_%T"` There is no way to tell tcsh to re-evaluate ...


0

Add to your crontab, and run it every minute. crontab -e Insert a line like that: * * * * * setenv now 'date +"%b_%d_%T"' Save and quit. Your variable will be updated every minute.


1

If you use the -prune option as suggested in this answer, the error message doesn't occur. Quoting from the above answer, Use -prune on the directories that you're going to delete anyway to tell find not to bother trying to find files in them. Testing mkdir koko cd koko touch file{1,2} cd .. find . -type d -name "koko" -prune -exec rm -rf {} \; ...


1

The problem is that find has found a directory, it matches your selection and then the command is executed. However, find wants to do what comes naturally, and that's recursing through a directory tree, but the directory it's just found has disappeared! Hence the error message. You can work around this by supplying the --depth option, which means process ...


3

Try this: sed '/CLKA/,/TEST1A/ { s/PortId = \"A/& B/; }' file This sed command appends the B character to the end of pattern PortId = "A which is between two words CLKA and TEST1A. Also you can use start(^) and end($) of line notifies to match/replace only PortId = "A" inside the CLKA { ... } module. ^ CLKA {$ matches the line which only contains ...


4

You have to escape ! to prevent csh/tcsh from performing history expansion. They still do history expansion though you wrote ! in single quote. Try: sed ':again;$\!N;$\!b again; s/{[^}]*}//g' file Or you can write a script an call with -f script.sed (Read sed FAQ).


-1

I am not familiar with tcsh but this sounds like a history expansion problem. In bash single quotes prevent history expansion, maybe in tcsh they don't. You may disable history expansion (I don't know how to do that, though; in bash this is done by set +H). Another option: Backslash escapes should work. Try sed_code=":again;\$\!N;\$\!b again; ...


1

Note that when you use ls with a pipe, the files are output a-line-at-a-time, allowing you to use grep and other filters; hence the following will work independently of the shell used (but will generate files on separate lines). ls | egrep "foo(uubar|)\.txt" If you want the columns back: ls | egrep "foo(uubar|)\.txt" | column


2

Here's a solution that works with tcsh. I'd use a brace expansion operator, {..}, like so: $ echo foo{,uubar}.txt foo.txt foouubar.txt This works by making a set of sub-strings that the string "foo" is alternatively added to. In this case we're using {,...} which means the first sub-string tried is nothing. The second sub-string is "uubar". References ...



Top 50 recent answers are included