Search Results

Search: Posts Made By: pandeesh
1,342
Posted By Scrutinizer
To add: you can simply replace the subshell...
To add: you can simply replace the subshell construct with code grouping
[[ $($adb_path devices|wc -l) -gt 2 ]] && echo "there's a device connected" || { echo "please connect a device";exit -1;}...
1,342
Posted By Don Cragun
As sea said, your exit commands are exiting the...
As sea said, your exit commands are exiting the subshell in which they're located; not the parent shell... But, you can reverse the condition and use multiple && operators with a single || operator....
1,342
Posted By sea
The && and || operators are not a replacement for...
The && and || operators are not a replacement for a proper if - else - fi block".

While one can use subshells, as you did, to do additional tasks if a false has returned, being a subshell, you...
4,862
Posted By Yoda
I guess there are non-printing characters in your...
I guess there are non-printing characters in your input file.

Use -v option with cat to show non-printing characters:
cat -v file
For further reference check the man page:
man cat
964
Posted By elixir_sinari
If you need the functionality of nohup, you could...
If you need the functionality of nohup, you could set a trap for SIGHUP to ignore it and ensure required redirections.
980
Posted By balajesuri
Read this...
Read this (http://perldoc.perl.org/functions/glob.html)
14,719
Posted By itkamaraj
try this... nohup ./script args >...
try this...

nohup ./script args > /tmp/out.txt &
916
Posted By RudiC
You need to do this in two steps: 1) append stdin...
You need to do this in two steps: 1) append stdin to file1 2) sort file1 to file2:$ cat >>file1; sort file1 >file2Or try this:$ cat file1 - | tee file1 | sort >file2But the second is highly...
1,773
Posted By Scrutinizer
Try: ls -d .*
Try: ls -d .*
1,582
Posted By bartus11
perl -0pe 's/a\nb/d/g' file
perl -0pe 's/a\nb/d/g' file
886
Posted By xbin
set +o history
set +o history
4,902
Posted By ctsgnb
@pandeesh getline x|store the next line in the...
@pandeesh
getline x|store the next line in the variable x and skip further display of that line until explictly requested with a print or printf command.
print $0","x|print the current line...
3,686
Posted By balajesuri
#! /bin/bash shopt -s extglob x=$1 ...
#! /bin/bash

shopt -s extglob

x=$1
while [ ${#x} -gt 0 ]
do
num=${x%%[a-zA-Z]*}; x=${x##+([0-9])}
str=${x%%[0-9]*}; x=${x##+([a-zA-Z])}
for ((i=1; i<=$num; i++))
do
...
3,686
Posted By balajesuri
Your code takes 0.02s on my machine!! I'm working...
Your code takes 0.02s on my machine!! I'm working on a server having 6 quad core cpu's each clocking 2.4 GHz and running on RHEL.

Try this. I don't claim it to be the most efficient. But still...
3,686
Posted By balajesuri
@max_hammer: I don't think [ "$x" =~ [0-9] ]...
@max_hammer: I don't think [ "$x" =~ [0-9] ] would work on bash 3.2 either.

I'm using GNU bash, version 3.2.25 and [ "$x" =~ [0-9] ] doesn't work. Regex matching is not supported by single square...
3,686
Posted By max_hammer
if [ "${ch}" -eq "3" -o "${ch}" -eq "4" ] ...
if [ "${ch}" -eq "3" -o "${ch}" -eq "4" ]


Should be


if [ "${ch}" = "3" -o "${ch}" = "4" ]

OR

if [ ${ch} -eq 3 -o ${ch} -eq 4 ]


= for comparing string
-eq for numbers
3,686
Posted By balajesuri
$ cat input 3a3b4c 4a5d2c 10a12b14c ...
$ cat input
3a3b4c
4a5d2c
10a12b14c
3abc4xyz5pqr
$
$ perl -ne 'chomp;print$2x$1while(/(\d+)(\D+)/g);print"\n"' input
aaabbbcccc
aaaadddddcc
aaaaaaaaaabbbbbbbbbbbbcccccccccccccc...
2,490
Posted By drl
Hi. The purpose is as noted, opens for both...
Hi.

The purpose is as noted, opens for both input and output:
Opening File Descriptors for Reading and Writing
The redirection operator

[n]<>word

causes the file whose name is the...
7,521
Posted By vbe
Start by checking in /etc/security/limits if...
Start by checking in /etc/security/limits if there is no tuning to do...

Found this:
1,110
Posted By Scott
Refer to the awk man page: A...
Refer to the awk man page:


A pattern-action statement has the form

pattern { action }

A missing { action } means print the line; a missing pattern always...
3,825
Posted By Scrutinizer
No, obviously, it will not go away entirely, but...
No, obviously, it will not go away entirely, but that is not what deprecation means. Of course anyone can keep using whatever they like. But is it is good practice on this forum to show solutions...
3,515
Posted By vbe
All files in /var/spool/cron/crontabs are owned...
All files in /var/spool/cron/crontabs are owned by root...
But nothing is stopping you to:

crontab -l >my.cronfile
vi my.cronfile #edit and modify to your needs...
crontab my.cronfile
1,580
Posted By balajesuri
sed '1s/^/Header\n/; $s/$/\nTrailer/' inputfile
sed '1s/^/Header\n/; $s/$/\nTrailer/' inputfile
1,580
Posted By Scott
awk 'BEGIN {print "Header"} END {print "Footer"}...
awk 'BEGIN {print "Header"} END {print "Footer"} 1' file
1,282
Posted By ctsgnb
@pandeesh : Remove the line : ...
@pandeesh :

Remove the line :

#!/bin/bashfrom your script, and give a try
Showing results 1 to 25 of 79

 

Featured Tech Videos

All times are GMT -4. The time now is 07:08 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy